赞
踩
1.编写serviceImpl实现类。(这个类主要编写发送短信)
@Resource JavaMailSender mailSender;//发送邮件对象 public void sendActivationMail(String maillTo, String activationCode) { //activationMailMessage 邮件信息对象 SimpleMailMessage activationMailMessage = new SimpleMailMessage(); String key = "activation"+maillTo;//收件方邮箱 activationMailMessage.setSubject("这是一个标题");//标题 activationMailMessage.setFrom("xieyong6352@foxmail.com");//发送人 //注入的简单邮件消息对象,设置收件方 activationMailMessage.setTo(maillTo); //设置邮件正文 activationMailMessage.setText("注册邮箱:"+maillTo+" 激活码:"+activationCode); //注入的邮件发送器,负责登录服务器,发送邮件 mailSender.send(activationMailMessage); //保存邮箱账号和激活码,到redis缓存中,30分钟后过期 redisService.set(key,activationCode,(long)30*60); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。