Commit 7cfa6685 authored by Roger Wu's avatar Roger Wu

捕获邮箱验证码异常

parent 3a613015
...@@ -34,19 +34,20 @@ public class SendEmailServiceImpl implements SendEmailService { ...@@ -34,19 +34,20 @@ public class SendEmailServiceImpl implements SendEmailService {
String code = RandomCodeUtils.generateNumber(6); String code = RandomCodeUtils.generateNumber(6);
String projectName = fmxParamConfigService.getParam("project.name"); String projectName = fmxParamConfigService.getParam("project.name");
String body = fmxParamConfigService.getParam("login.email.send.body"); String body = fmxParamConfigService.getParam("login.email.send.body");
body = body.replaceAll("\\$\\{projectName}",projectName) body = body.replaceAll("\\$\\{projectName}", projectName)
.replaceAll("\\$\\{emailAddress}",emailAddress) .replaceAll("\\$\\{emailAddress}", emailAddress)
.replaceAll("\\$\\{authCode}",code) .replaceAll("\\$\\{authCode}", code)
.replaceAll("\\$\\{CurrDate}",DateUtils.getCurrDate()); .replaceAll("\\$\\{CurrDate}", DateUtils.getCurrDate());
entity.setBody(body); entity.setBody(body);
entity.setSubject("用户邮箱校验");
List<String> list = new LinkedList<>(); List<String> list = new LinkedList<>();
list.add(emailAddress); list.add(emailAddress);
entity.setTo(list); //接收者 entity.setTo(list); //接收者
if(emailSenderService.sendMail(entity,null)){ try {
// 如果成功发送,则把验证码存入redis当中,并设置15分钟的过期时间 // 如果成功发送,则把验证码存入redis当中,并设置15分钟的过期时间
emailSenderService.sendMail(entity, null);
redisService.set(emailAddress, code, 900); redisService.set(emailAddress, code, 900);
} else { } catch (Exception e) {
throw new BusinessException("验证码发送失败!请重试"); throw new BusinessException("验证码发送失败!请重试");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment