fix 邮件发送 账号信息装载 在convert中处理

This commit is contained in:
wangjingyi 2022-03-26 08:06:32 +08:00
parent bd86b89ea5
commit e4326036f8
2 changed files with 14 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.convert.mail; package cn.iocoder.yudao.module.system.convert.mail;
import cn.hutool.extra.mail.MailAccount;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountBaseVO; import cn.iocoder.yudao.module.system.controller.admin.mail.vo.account.MailAccountBaseVO;
import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
@ -19,4 +20,15 @@ public interface MailAccountConvert {
PageResult<MailAccountBaseVO> convertPage(PageResult<MailAccountDO> pageResult); PageResult<MailAccountBaseVO> convertPage(PageResult<MailAccountDO> pageResult);
List<MailAccountBaseVO> convertList02(List<MailAccountDO> list); List<MailAccountBaseVO> convertList02(List<MailAccountDO> list);
default MailAccount convertAccount(MailAccountDO mailAccountDO){
return new MailAccount()
.setHost(mailAccountDO.getHost())
.setPort(mailAccountDO.getPort())
.setAuth(true)
.setFrom(mailAccountDO.getFrom())
.setUser(mailAccountDO.getUsername())
.setPass(mailAccountDO.getPassword())
.setSslEnable(mailAccountDO.getSslEnable());
};
} }

View File

@ -106,14 +106,8 @@ public class MailAccountServiceImpl implements MailAccountService {
//List<String> fileIds = mailSendVO.getFileIds(); //List<String> fileIds = mailSendVO.getFileIds();
//装载账号信息 //装载账号信息
MailAccount account = new MailAccount(); MailAccount account = MailAccountConvert.INSTANCE.convertAccount(mailAccountDO);
account.setHost(mailAccountDO.getHost());
account.setPort(mailAccountDO.getPort());
account.setAuth(true);
account.setFrom(mailAccountDO.getFrom());
account.setUser(mailAccountDO.getUsername());
account.setPass(mailAccountDO.getPassword());
account.setSslEnable(mailAccountDO.getSslEnable());
//发送 //发送
MailUtil.send(account , mailSendVO.getTos() , mailSendVO.getTitle() , mailSendVO.getContent() , false); MailUtil.send(account , mailSendVO.getTos() , mailSendVO.getTitle() , mailSendVO.getContent() , false);
} }