<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans><bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host"> <value>smtp.163.com</value> </property><property name="javaMailProperties"><props><!-- 如果要使用用户名和密码验证,这一步需要 -->
<prop key="mail.smtp.auth">true</prop> </props> </property><property name="username"> <value>yong hu ming </value></property><property name="password"> <value>mi ma</value></property></bean><!-- 简单的message -->
<bean id="mailMessage" class="org.springframework.mail.SimpleMailMessage"><property name="to"><value>shou jian ren</value></property><property name="from"><value>ni de you xiang di zhi</value></property><property name="subject"> <!-- Email 标题 --><value>A Spring Mail sender test to my baoyaer</value></property></bean><!-- 测试发送的类 -->
<bean id="testMailSender" class="test.SpringMail.TestSenderMail"><property name="mailMessage"><ref bean="mailMessage"/></property><property name="mailSender"><ref bean="mailSender"/></property></bean>
</beans>