1.使用Spring发送带附件的电子邮件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <bean > <property name="host" value="192.168.8.71"></property><!-- 服务器 --> <property name="port" value="25"></property><!-- 端口 --> <property name="username" value="wxk"></property><!-- 用户名 --> <property name="password" value="wxk"></property><!-- 密码 --> <property name="protocol" value="smtp" ></property><!-- 协议 --> <property name="defaultEncoding" value="utf-8"></property><!-- 默认编码 --> <property name="javaMailProperties"> <props> <!-- 设置SMTP服务器需要用户验证 --> <prop key="mail.smtp.auth">true</prop> </props> </property> </bean> <bean > <property name="mailSender" ref="mailSender"></property> </bean> </beans>