package cn.hxex.library.service.impl;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import cn.hxex.library.model.Email;
import cn.hxex.library.service.EmailService;
public class EmailServiceImpl implements EmailService{
public Email sendEmail(String subject, String object){
JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
// 设定 Mail Server
senderImpl.setHost("smtp.qq.com");
//SMTP验证时,需要用户名和密码
senderImpl.setUsername("####");
senderImpl.setPassword("####");
// 建立邮件讯息
SimpleMailMessage mailMessage = new SimpleMailMessage();
// 设定收件人、寄件人、主题与内文
mailMessage.setTo("####@qq.com");
mailMessage.setFrom("####@qq.com");
mailMessage.setSubject(subject);
mailMessage.setText(object);
// 传送邮件
//senderImpl.send(mailMessage);就是这句一加上就错了!!!
System.out.println("邮件传送OK..");
return null;
}
}
慕的地6264312
相关分类