spring 邮件
来源:互联网 发布:微信请帖软件 编辑:程序博客网 时间:2024/06/17 21:18
一、普通邮件
(1)java 代码:
import org.springframework.mail.MailException;import org.springframework.mail.MailSender;import org.springframework.mail.SimpleMailMessage;public class SimpleOrderManager implements OrderManager { private MailSender mailSender; private SimpleMailMessage templateMessage; public void setMailSender(MailSender mailSender) { this.mailSender = mailSender; } public void setTemplateMessage(SimpleMailMessage templateMessage) { this.templateMessage = templateMessage; } @Override public void placeOrder() { SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setTo("xxxxxxxx@qq.com"); msg.setText(" thank you for placing order. Your order number is "); try{ this.mailSender.send(msg); } catch(MailException ex) { // simply log it and go on... System.err.println(ex.getMessage()); } }}
(2)spring配置文件
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="smtp.126.com"/> <property name="username" value="xxxxx"/> <property name="password" value="xxxxx"/> <property name="defaultEncoding" value="UTF-8"/> <property name="javaMailProperties"> <props> <prop key="mail.smtp.auth">true</prop> </props> </property> </bean> <bean id="templateMessage" class="org.springframework.mail.SimpleMailMessage"> <property name="from" value="xxxxx@126.com"/> <property name="subject" value="Your order"/> </bean> <bean id="orderManager" class="com.spring.test.mail.SimpleOrderManager"> <property name="mailSender" ref="mailSender"/> <property name="templateMessage" ref="templateMessage"/> </bean>
- spring邮件
- spring 邮件
- 邮件操作 (spring发送邮件)
- Spring 发送邮件 简单邮件
- Spring 发送邮件 HTML邮件
- 【Spring】使用Spring发送邮件
- 【Spring】使用Spring发送邮件
- 【Spring】使用Spring发送邮件
- 【Spring】使用Spring发送邮件
- 【Spring】使用Spring发送邮件
- spring邮件发送例
- 使用spring发送邮件
- Spring配置邮件服务
- Spring中发送邮件
- spring收发邮件
- spring各种邮件发送
- spring各种邮件发送
- Spring发送邮件
- linux中select的事例
- C#求数组中前K大的数
- JSon文件解析
- oracle根据外键名查关联的表
- C++面向对象(学习笔记)
- spring 邮件
- 设计模式(学习笔记)
- hdu1263水果 STL map的使用
- 增强事务复制性能
- Android杂谈--网络状态判断
- NTP介绍
- 字体和文本布局(Fonts and TextLayout)
- 解释ASP.NET中用户控件UserControl不能被拖曳大小的原因
- *sort的一些用法*