diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailAccountConvert.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailAccountConvert.java index a288dd84a..fe768efbd 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailAccountConvert.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/mail/MailAccountConvert.java @@ -1,5 +1,6 @@ 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.module.system.controller.admin.mail.vo.account.MailAccountBaseVO; import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO; @@ -19,4 +20,15 @@ public interface MailAccountConvert { PageResult convertPage(PageResult pageResult); List convertList02(List 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()); + }; } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailAccountServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailAccountServiceImpl.java index 98aa646c7..0c0d86eba 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailAccountServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/mail/impl/MailAccountServiceImpl.java @@ -106,14 +106,8 @@ public class MailAccountServiceImpl implements MailAccountService { //List fileIds = mailSendVO.getFileIds(); //装载账号信息 - MailAccount account = new MailAccount(); - 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()); + MailAccount account = MailAccountConvert.INSTANCE.convertAccount(mailAccountDO); + //发送 MailUtil.send(account , mailSendVO.getTos() , mailSendVO.getTitle() , mailSendVO.getContent() , false); }