一:pom.xml
javax.mail
1.4.7
二:mail.properties
mail.host=smtp.hsmdata.com
mail.username=**@hsmdata.com
mail.password=**
三:applicationContext.xml
true
25000
四: 使用
@Autowired
private JavaMailSender mailSender;
public void toEmail(SimpleMailMessage mail){
mailSender.send(mail);
}
String str = String.valueOf(Math.round(Math.random() * 1000000));
SimpleMailMessage mail = new SimpleMailMessage();
mail.setTo(email);
mail.setFrom(PropertiesUtil.getProperty(PropertiesConstant.MAIL_USERNAME));
mail.setSubject("价值连城项目验证邮件");
mail.setText("尊敬的用户:您好,感谢您使用价值连城项目,您的验证码为" + str + "。");