xinyb
2024-09-20 0c7568c19ebdb540d5cca242eb9e95231d1a0dd7
提交 | 用户 | age
f51ff9 1 package com.yc.crm.mail.action;
X 2
877259 3 import com.sun.mail.imap.IMAPStore;
X 4 import com.yc.action.mail.EmailConfigUtils;
385e2d 5 import com.yc.crm.mail.entity.T482102Entity;
X 6 import com.yc.crm.mail.service.MailAccountIfc;
7 import com.yc.crm.mail.service.MailIfc;
f51ff9 8 import com.yc.crm.mail.util.AllBackMsg;
X 9 import com.yc.entity.DataSourceEntity;
10 import com.yc.multiData.MultiDataSource;
11 import com.yc.multiData.SpObserver;
12 import com.yc.utils.SessionKey;
13 import org.apache.commons.lang3.StringUtils;
14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.web.bind.annotation.*;
16
428443 17 import javax.mail.*;
f51ff9 18 import javax.servlet.http.HttpServletRequest;
X 19 import javax.servlet.http.HttpServletResponse;
20 import javax.servlet.http.HttpSession;
428443 21 import java.util.HashMap;
f51ff9 22 import java.util.List;
428443 23 import java.util.Map;
X 24 import java.util.Properties;
f51ff9 25
X 26 /**
27  * @BelongsProject: eCoWorksV3
28  * @BelongsPackage: com.yc.crm.action
29  * @author: xinyb
30  * @CreateTime: 2024-07-19  17:33
385e2d 31  * @Description: 个人邮箱配置
f51ff9 32  */
X 33 @CrossOrigin
34 @RestController
385e2d 35 @RequestMapping("/crm/mail/account")
X 36 public class MailAccount {
f51ff9 37
X 38     @Autowired
385e2d 39     MailAccountIfc mailAccountIfc;
X 40     @Autowired
41     MailIfc mailIfc;
f51ff9 42
X 43     /**
44      * 添加邮箱配置信息
45      *
46      * @param account
47      * @param request
48      * @param response
49      * @return
50      */
385e2d 51     @PostMapping("/addAccount.do")
X 52     public AllBackMsg addAccount(@RequestBody T482102Entity account, HttpServletRequest request, HttpServletResponse response) {
f51ff9 53         AllBackMsg msg = new AllBackMsg();
X 54         try {
55             if (StringUtils.isBlank(account.getEmail())) {
8c1986 56                 msg.setFail("请输入邮箱账号");
X 57                 return msg;
58             }
877259 59             if (account.getMailType().equals(0) || account.getMailType().equals(1)) {
8c1986 60                 if (StringUtils.isBlank(account.getPassword())) {
X 61                     msg.setFail("请输入邮箱密码");
62                     return msg;
63                 }
513b8e 64                 account.setReceiveEmail(account.getEmail());
X 65                 account.setReceivePassword(account.getPassword());
66                 account.setSmtpEmail(account.getEmail());
67                 account.setSmtpPassword(account.getPassword());
877259 68             }
X 69             if (account.getMailType().equals(1) || account.getMailType().equals(2)) {
70                 if (StringUtils.isBlank(account.getReceiveProtocol())) {
71                     msg.setFail("请选择协议类型");
8c1986 72                     return msg;
X 73                 }
877259 74                 if (StringUtils.isBlank(account.getReceiveHost())) {
X 75                     msg.setFail("请输入收邮件服务器");
8c1986 76                     return msg;
X 77                 }
877259 78                 if (account.getReceivePort().equals(0)) {
X 79                     msg.setFail("请输入收邮件服务器端口");
8c1986 80                     return msg;
X 81                 }
877259 82                 if (StringUtils.isBlank(account.getSmtpHost())) {
X 83                     msg.setFail("请输入发邮件服务器");
8c1986 84                     return msg;
X 85                 }
877259 86                 if (account.getSmtpPort().equals(0)) {
X 87                     msg.setFail("请输入发邮件服务器端口");
88                     return msg;
89                 }
90                 if (account.getMailType().equals(2)) {
91                     if (StringUtils.isBlank(account.getReceiveEmail())) {
92                         msg.setFail("请输入收件账号");
93                         return msg;
94                     }
95                     if (StringUtils.isBlank(account.getReceivePassword())) {
96                         msg.setFail("请输入收件密码");
97                         return msg;
98                     }
99                     if (StringUtils.isBlank(account.getSmtpEmail())) {
100                         msg.setFail("请输入发件账号");
101                         return msg;
102                     }
103                     if (StringUtils.isBlank(account.getSmtpPassword())) {
104                         msg.setFail("请输入发件密码");
105                         return msg;
106                     }
107                 }
f51ff9 108             }
X 109             HttpSession session = request.getSession();
110             String companyId = (String) session.getAttribute(SessionKey.COMPANY_ID);
111             String companyName = (String) session.getAttribute(SessionKey.COMPANY_NAME);
112             String userCode = (String) session.getAttribute(SessionKey.USERCODE);
113             String userName = (String) session.getAttribute(SessionKey.USER_NAME);
114             account.setCompanyId(companyId);
115             account.setCompanyName(companyName);
116             account.setUserCode(userCode);
117             account.setUserName(userName);
877259 118             if (account.getMailType().equals(0)) {
X 119                 //初始配置
120                 getMailConfigProperties(account);
121             }
f51ff9 122             DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
X 123             SpObserver.setDBtoInstance("_" + dataSource.getDbId());
877259 124             //邮件检测
X 125             String error = emailDetection(account);
126             if (StringUtils.isNotBlank(error)) {
127                 account.setMailStatus("异常");
128             }
385e2d 129             mailAccountIfc.addEmailAccount(account);//添加新的邮箱配置
428443 130             Map<String, Object> map = new HashMap<>();
877259 131             if (StringUtils.isBlank(error)) {
7caeae 132                 map.put("code", 0);
877259 133                 map.put("companyId", companyId);
X 134                 map.put("companyName", companyName);
135                 map.put("userCode", userCode);
136                 map.put("userName", userName);
137                 map.put("email", account.getEmail());
138                 msg.setSuccess("已保存", map);
139             } else {
7caeae 140                 map.put("code", -1);
877259 141                 map.put("mailStatus", "异常");
X 142                 map.put("error", error);
143                 msg.setSuccess("执行成功", map);
144             }
145         } catch (Exception e) {
146             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
147         } finally {
148             SpObserver.setDBtoInstance();
149         }
150         return msg;
151     }
152
153     /**
154      * 添加别名邮箱
155      *
156      * @param account
157      * @param request
158      * @param response
159      * @return
160      */
161     @GetMapping("/addAliasEmail.do")
162     public AllBackMsg addAliasEmail(String aliasEmail, Integer accountId, HttpServletRequest request, HttpServletResponse response) {
163         AllBackMsg msg = new AllBackMsg();
164         try {
165             if (StringUtils.isBlank(aliasEmail)) {
166                 msg.setFail("请输入别名邮箱");
167                 return msg;
168             }
169             if (accountId.equals(0)) {
170                 msg.setFail("邮箱账号Id不能为空");
171                 return msg;
172             }
173             HttpSession session = request.getSession();
174             String userCode = (String) session.getAttribute(SessionKey.USERCODE);
175             if (StringUtils.isBlank(userCode)) {
176                 msg.setFail("登录用户已过期,请检查");
177                 return msg;
178             }
179             DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
180             SpObserver.setDBtoInstance("_" + dataSource.getDbId());
181             T482102Entity t482102Entity = mailAccountIfc.getAccountInfo(userCode, accountId);
182             if (t482102Entity.getMailType().equals(0) || t482102Entity.getMailType().equals(1)) {
183                 t482102Entity.setEmail(aliasEmail);
184                 t482102Entity.setReceiveEmail(aliasEmail);
185                 t482102Entity.setSmtpEmail(aliasEmail);
186             }
187             //邮箱检测
188             String error = emailDetection(t482102Entity);
189             Map<String, Object> map = new HashMap<>();
190             if (StringUtils.isBlank(error)) {
191                 mailAccountIfc.updateAliasEmail(aliasEmail, accountId);
7caeae 192                 map.put("code", 0);
877259 193                 map.put("userCode", userCode);
X 194                 map.put("aliasEmail", aliasEmail);
195                 map.put("accountId", accountId);
196                 msg.setSuccess("已保存", map);
197             } else {
7caeae 198                 map.put("code", -1);
877259 199                 map.put("mailStatus", "异常");
X 200                 map.put("error", error);
201                 msg.setSuccess("执行成功", map);
202             }
f51ff9 203         } catch (Exception e) {
f5cc47 204             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
f51ff9 205         } finally {
X 206             SpObserver.setDBtoInstance();
207         }
208         return msg;
209     }
210
211     /**
212      * 更新邮箱配置信息
213      *
214      * @param account
215      * @param request
216      * @param response
217      * @return
218      */
385e2d 219     @PostMapping("/updateAccount.do")
3c2c1b 220     public AllBackMsg updateAccount(@RequestBody T482102Entity account, HttpServletRequest request, HttpServletResponse response) {
f51ff9 221         AllBackMsg msg = new AllBackMsg();
X 222         try {
428443 223             if (account.getAccountId() == 0) {
f5cc47 224                 msg.setFail("获取不到邮箱配置ID,请检查");
X 225                 return msg;
226             }
8c1986 227             if (StringUtils.isBlank(account.getEmail())) {
X 228                 msg.setFail("请输入邮箱账号");
229                 return msg;
230             }
231             if (account.getMailType().equals(0)) {
877259 232                 account.setMailType(1);
X 233             }
234             if (account.getMailType().equals(1)) {
8c1986 235                 if (StringUtils.isBlank(account.getPassword())) {
X 236                     msg.setFail("请输入邮箱密码");
237                     return msg;
238                 }
239                 account.setReceiveEmail(account.getEmail());
240                 account.setReceivePassword(account.getPassword());
241                 account.setSmtpEmail(account.getEmail());
242                 account.setSmtpPassword(account.getPassword());
877259 243             } else if (account.getMailType().equals(2)) {
8c1986 244                 if (StringUtils.isBlank(account.getReceiveEmail())) {
X 245                     msg.setFail("请输入收件账号");
246                     return msg;
247                 }
248                 if (StringUtils.isBlank(account.getReceivePassword())) {
249                     msg.setFail("请输入收件密码");
250                     return msg;
251                 }
252                 if (StringUtils.isBlank(account.getSmtpEmail())) {
253                     msg.setFail("请输入发件账号");
254                     return msg;
255                 }
256                 if (StringUtils.isBlank(account.getSmtpPassword())) {
257                     msg.setFail("请输入发件密码");
258                     return msg;
259                 }
260             }
261             if (StringUtils.isBlank(account.getReceiveHost())) {
262                 msg.setFail("请输入收邮件服务器");
263                 return msg;
264             }
265             if (account.getReceivePort().equals(0)) {
266                 msg.setFail("请输入收邮件服务器端口");
267                 return msg;
268             }
269             if (StringUtils.isBlank(account.getSmtpHost())) {
270                 msg.setFail("请输入发邮件服务器");
271                 return msg;
272             }
273             if (account.getSmtpPort().equals(0)) {
274                 msg.setFail("请输入发邮件服务器端口");
275                 return msg;
276             }
f51ff9 277             HttpSession session = request.getSession();
f5cc47 278             String userCode = (String) session.getAttribute(SessionKey.USERCODE);
428443 279             String userName = (String) session.getAttribute(SessionKey.USER_NAME);
X 280             if (StringUtils.isBlank(userCode)) {
f5cc47 281                 msg.setFail("登录用户已过期,请检查");
X 282                 return msg;
283             }
284             account.setUserCode(userCode);
f51ff9 285             DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
X 286             SpObserver.setDBtoInstance("_" + dataSource.getDbId());
385e2d 287             mailAccountIfc.updateEmailAccount(account);
877259 288             String error = emailDetection(account);
428443 289             Map<String, Object> map = new HashMap<>();
877259 290             if (StringUtils.isBlank(error)) {
7caeae 291                 map.put("code", 0);
877259 292                 map.put("userCode", userCode);
X 293                 map.put("userName", userName);
294                 map.put("email", account.getEmail());
295                 msg.setSuccess("已更新", map);
296             } else {
297                 //异常处理
298                 mailAccountIfc.updateMailStatus("异常", account.getAccountId());
7caeae 299                 map.put("code", -1);
877259 300                 map.put("mailStatus", "异常");
X 301                 map.put("error", error);
302                 msg.setSuccess("执行成功", map);
303             }
f51ff9 304         } catch (Exception e) {
f5cc47 305             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
385e2d 306         } finally {
X 307             SpObserver.setDBtoInstance();
f51ff9 308         }
X 309         return msg;
310     }
311
312     /**
313      * 删除邮箱配置信息
314      *
315      * @param account
316      * @param request
317      * @param response
318      * @return
319      */
385e2d 320     @PostMapping("/deleteAccount.do")
X 321     public AllBackMsg deleteAccount(@RequestParam(defaultValue = "0") Integer accountId, HttpServletRequest request, HttpServletResponse response) {
f51ff9 322         AllBackMsg msg = new AllBackMsg();
X 323         try {
385e2d 324             if (accountId == 0) {
X 325                 msg.setFail("邮箱编号ID获取不到");
326                 return msg;
327             }
328             HttpSession session = request.getSession();
329             String userCode = (String) session.getAttribute(SessionKey.USERCODE);
428443 330             if (StringUtils.isBlank(userCode)) {
f5cc47 331                 msg.setFail("登录用户已过期,请检查");
X 332                 return msg;
333             }
385e2d 334             DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
X 335             SpObserver.setDBtoInstance("_" + dataSource.getDbId());
336             Integer cont = mailAccountIfc.deleteEmailAccount(userCode, accountId);
337             if (cont > 0) {
f5cc47 338                 msg.setOk("已删除");
385e2d 339             }
f51ff9 340         } catch (Exception e) {
f5cc47 341             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
385e2d 342         } finally {
X 343             SpObserver.setDBtoInstance();
f51ff9 344         }
385e2d 345         return msg;
f51ff9 346     }
X 347
348     /**
877259 349      * 查询邮箱配置列表
f51ff9 350      *
385e2d 351      * @param search   搜索
f51ff9 352      * @param request
X 353      * @param response
354      * @return
355      */
6a63e2 356     @GetMapping("/getAccountList.do")
X 357     public AllBackMsg getAccountList(HttpServletRequest request, HttpServletResponse response) {
f51ff9 358         AllBackMsg msg = new AllBackMsg();
X 359         try {
360             HttpSession session = request.getSession();
385e2d 361             String userCode = (String) session.getAttribute(SessionKey.USERCODE);
X 362             DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
363             SpObserver.setDBtoInstance("_" + dataSource.getDbId());
877259 364             List<T482102Entity> t482102Entities = mailAccountIfc.getAccount(userCode);
385e2d 365             if (t482102Entities.size() > 0) {
6a63e2 366                 msg.setSuccess("执行成功", t482102Entities);
428443 367             } else {
f5cc47 368                 msg.setFail("未找到配置信息,0条数据");
6a63e2 369             }
X 370         } catch (Exception e) {
371             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
372         } finally {
373             SpObserver.setDBtoInstance();
374         }
375         return msg;
376     }
377
378
379     /**
380      * 查询个人邮箱信息
381      *
382      * @param search   搜索
383      * @param request
384      * @param response
385      * @return
386      */
387     @GetMapping("/getAccount.do")
388     public AllBackMsg getAccount(String mail, HttpServletRequest request, HttpServletResponse response) {
389         AllBackMsg msg = new AllBackMsg();
390         try {
391             if (StringUtils.isBlank(mail)) {
392                 msg.setFail("参数 邮件账号 不能为空");
393                 return msg;
394             }
395             HttpSession session = request.getSession();
396             String userCode = (String) session.getAttribute(SessionKey.USERCODE);
397             DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
398             SpObserver.setDBtoInstance("_" + dataSource.getDbId());
399             T482102Entity t482102Entities = mailAccountIfc.getAccountInfo(userCode, mail);
400             if (StringUtils.isNotBlank(t482102Entities.getEmail())) {
401                 msg.setSuccess("执行成功", t482102Entities);
402             } else {
403                 msg.setFail("未找到配置信息");
f51ff9 404             }
X 405         } catch (Exception e) {
f5cc47 406             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
f51ff9 407         } finally {
X 408             SpObserver.setDBtoInstance();
409         }
385e2d 410         return msg;
f51ff9 411     }
428443 412
X 413     /**
414      * 检测绑定是否有效
415      *
416      * @param email
417      * @param request
418      * @param response
419      * @return
420      */
421     @GetMapping("/isEmailValid.do")
422     public AllBackMsg isEmailValid(String email, HttpServletRequest request, HttpServletResponse response) {
423         AllBackMsg msg = new AllBackMsg();
877259 424
428443 425         try {
X 426             HttpSession session = request.getSession();
427             String userCode = (String) session.getAttribute(SessionKey.USERCODE);
428             if (StringUtils.isBlank(userCode)) {
429                 msg.setFail("登录用户已过期,请检查");
430                 return msg;
431             }
432             if (StringUtils.isBlank(email)) {
433                 msg.setFail("检测绑定邮箱不能为空");
434                 return msg;
435             }
436             DataSourceEntity dataSource = MultiDataSource.getDataSourceMap(request);//获取数据源
437             SpObserver.setDBtoInstance("_" + dataSource.getDbId());
438             //根据当前用户查询绑定的邮箱信息
439             T482102Entity emailEntity = mailAccountIfc.getAccountInfo(userCode, email);//返回邮箱的账号信息
440             if (emailEntity == null || StringUtils.isBlank(emailEntity.getEmail())) {
441                 msg.setFail("找不到邮箱:" + email + "配置信息请完善。");
442                 return msg;
443             }
877259 444             String error = emailDetection(emailEntity);
6a63e2 445             Map<String, Object> map = new HashMap<>();
877259 446             if (StringUtils.isBlank(error)) {
7caeae 447                 map.put("code", 0);
877259 448                 map.put("email", emailEntity.getEmail());
X 449                 map.put("protocol", emailEntity.getReceiveProtocol());
450                 map.put("receiveHost", emailEntity.getReceiveHost());
451                 map.put("receiveSSL", emailEntity.isReceiveSSL());
452                 map.put("receivePort", emailEntity.getReceivePort());
453                 map.put("smtpHost", emailEntity.getSmtpHost());
454                 map.put("smtpSSL", emailEntity.isSmtpSSL());
455                 map.put("smtpPort", emailEntity.getSmtpPort());
456                 map.put("proxyFlag", emailEntity.isProxyFlag());
457                 map.put("biSyncFlag", emailEntity.isBiSyncFlag());
7cf738 458                 map.put("mailStatus", "正常");
877259 459                 msg.setSuccess("执行成功", map);
X 460             } else {
461                 //异常处理
462                 mailAccountIfc.updateMailStatus("异常", emailEntity.getAccountId());
7caeae 463                 map.put("code", -1);
877259 464                 map.put("mailStatus", "异常");
X 465                 map.put("error", error);
466                 msg.setSuccess("执行成功", map);
467             }
428443 468         } catch (MessagingException e) {
X 469             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
470         } catch (Exception e) {
471             msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
472         } finally {
473             SpObserver.setDBtoInstance();
474         }
475         return msg;
476     }
877259 477
X 478     /**
479      * 邮箱检测
480      *
481      * @param emailEntity
482      * @return
483      * @throws MessagingException
484      */
485     private String emailDetection(T482102Entity emailEntity) throws MessagingException {
486         String errorMsg = "";
487         try {
048b74 488             String protocol = emailEntity.getReceiveProtocol().toLowerCase();//接收协议 imap pop3
877259 489             Properties props = new Properties();
048b74 490             props.put("mail.store.protocol", protocol);//指定接收的邮件协议 IMAP over pop3
X 491             if (protocol.contains("imap")) {
492                 props.put("mail.imaps.host", emailEntity.getReceiveHost());
493                 props.put("mail.imaps.port", emailEntity.getReceivePort());
494             } else if (protocol.contains("pop3")) {
495                 props.put("mail.pop3.host", emailEntity.getReceiveHost());
496                 props.put("mail.pop3.port", emailEntity.getReceivePort());
497             } else {
498                 props.put("mail.imaps.host", emailEntity.getReceiveHost());
499                 props.put("mail.imaps.port", emailEntity.getReceivePort());
500             }
501 //            props.put("mail.imap.ssl.enable", emailEntity.isReceiveSSL()+""); // 使用 SSL 连接
502 //            props.put("mail.imap.starttls.enable", "true");//// IMAP 协议设置 STARTTLS
877259 503
048b74 504             props.put("mail.smtp.auth", "true");
X 505             props.put("mail.smtp.ssl.enable", emailEntity.isSmtpSSL() + "");//启用SSL
877259 506             props.put("mail.smtp.host", emailEntity.getSmtpHost()); // 替换为你的SMTP服务器
X 507             props.put("mail.smtp.port", emailEntity.getSmtpPort()); // 或者你使用的端口
048b74 508
X 509 //            props.put("mail.smtp.starttls.enable", "true");//启用tls
510 //            props.setProperty("mail.smtp.socketFactory.port", "587");//启用tls后port:587
511
877259 512
X 513             HashMap IAM = new HashMap();
514             //带上IMAP ID信息,由key和value组成,例如name,version,vendor,support-email等。
515             IAM.put("name", emailEntity.getReceiveEmail());
516             IAM.put("version", emailEntity.getDocVersion() + "");
517             IAM.put("vendor", emailEntity.getCompanyName());
518             IAM.put("support-email", emailEntity.getEmail());
519
520             //创建会话
521             Session session = Session.getInstance(props, new Authenticator() {
522                 @Override
523                 protected PasswordAuthentication getPasswordAuthentication() {
524                     return new PasswordAuthentication(emailEntity.getReceiveEmail(), emailEntity.getReceivePassword());
525                 }
526             });
527
528             //存储对象
048b74 529             IMAPStore store = (IMAPStore) session.getStore(protocol);//imap协议或pop3协议类型(推荐你使用IMAP协议来存取服务器上的邮件。)
877259 530             //连接
X 531             store.connect(emailEntity.getReceiveHost(), emailEntity.getReceiveEmail(), emailEntity.getReceivePassword());
532             store.id(IAM);//163邮箱需要,不然会报:A3 NO SELECT Unsafe Login. Please contact kefu@188.com for help
533             Folder folder = null;
534             // 获得收件箱
535             folder = store.getFolder("INBOX");
536             // 以读写模式打开收件箱
537             folder.open(Folder.READ_WRITE);
538             folder.close(false);
539             store.close();
540
541             Transport transport = session.getTransport();
542             transport.connect();
543             transport.close();
7cf738 544             mailAccountIfc.updateMailStatus("正常", emailEntity.getAccountId());
877259 545         } catch (MessagingException e) {
X 546             errorMsg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
547         } catch (Exception e) {
548             errorMsg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage();
549         }
550         return errorMsg;
551     }
552
553     private T482102Entity getMailConfigProperties(T482102Entity t482102) {
554         try {
555             String email = t482102.getEmail();
556             int index = email.lastIndexOf("@");
557             String emailSuffix = email.substring(index + 1).toLowerCase();//邮箱后缀
558             String port = "";
559             t482102.setReceiveHost(EmailConfigUtils.getMailConfig("mail.imap.host." + emailSuffix));
560             t482102.setSmtpHost(EmailConfigUtils.getMailConfig("mail.smtp.host." + emailSuffix));
561             port = EmailConfigUtils.getMailConfig("mail.imap.port." + emailSuffix);
562             if (StringUtils.isNotBlank(port)) {
563                 t482102.setReceivePort(Integer.parseInt(port));
564             }
565             port = EmailConfigUtils.getMailConfig("mail.smtp.port." + emailSuffix);
566             if (StringUtils.isNotBlank(port)) {
567                 t482102.setSmtpPort(Integer.parseInt(port));
568             }
569         } catch (Exception e) {
570             return t482102;
571         }
572         return t482102;
573     }
f51ff9 574 }