update 回滚邮件发送通用功能

This commit is contained in:
lijiarao
2023-02-17 14:56:52 +08:00
parent 101c7a4153
commit ef50e6cf4b
@@ -110,29 +110,28 @@ public class SendMessageServiceImpl implements SendMessageService {
throw new JeroBootException("邮件发送,邮箱地址不能为空!");
}
try {
throw new JeroBootException("邮件发送失败,发件人的邮箱或邮箱授权码错误!");
//String email = loginUser.getEmail();
//String emailPassword = loginUser.getEmailPassword();
////如果发件人没有邮箱或邮箱授权码则使用admin账户的邮箱授权码
//if (StringUtils.isBlank(email) || StringUtils.isBlank(emailPassword)) {
// loginUser = sysBaseAPI.getUserByName(env.getProperty("message.systemEmailUser"));
// email = loginUser.getEmail();
// emailPassword = loginUser.getEmailPassword();
//}
//email = PasswordUtil.decrypt(email);
//emailPassword = PasswordUtil.decrypt(emailPassword);
//EmailSendMsgHandle emailHandle = new EmailSendMsgHandle(email,emailPassword);
//// 发送带附件邮箱
//if(!CollectionUtils.isEmpty(sendMessageDTO.getListFile())){
// emailHandle.SendMsgAndFile(sendMessageDTO.getEmail(), title, content,sendMessageDTO.getListFile());
//}else{
// //如果有通知内容就替换
// if (StringUtils.isNotBlank(sendMessageDTO.getMeetingNotice())){
// emailHandle.SendMsg(sendMessageDTO.getEmail(), title, sendMessageDTO.getMeetingNotice());
// }else {
// emailHandle.SendMsg(sendMessageDTO.getEmail(), title, content);
// }
//}
String email = loginUser.getEmail();
String emailPassword = loginUser.getEmailPassword();
//如果发件人没有邮箱或邮箱授权码则使用admin账户的邮箱授权码
if (StringUtils.isBlank(email) || StringUtils.isBlank(emailPassword)) {
loginUser = sysBaseAPI.getUserByName(env.getProperty("message.systemEmailUser"));
email = loginUser.getEmail();
emailPassword = loginUser.getEmailPassword();
}
email = PasswordUtil.decrypt(email);
emailPassword = PasswordUtil.decrypt(emailPassword);
EmailSendMsgHandle emailHandle = new EmailSendMsgHandle(email,emailPassword);
// 发送带附件邮箱
if(!CollectionUtils.isEmpty(sendMessageDTO.getListFile())){
emailHandle.SendMsgAndFile(sendMessageDTO.getEmail(), title, content,sendMessageDTO.getListFile());
}else{
//如果有通知内容就替换
if (StringUtils.isNotBlank(sendMessageDTO.getMeetingNotice())){
emailHandle.SendMsg(sendMessageDTO.getEmail(), title, sendMessageDTO.getMeetingNotice());
}else {
emailHandle.SendMsg(sendMessageDTO.getEmail(), title, content);
}
}
}catch (Exception e){
log.error("发送邮件异常",e);
if (e.getMessage() !=null){