diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyMailUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyMailUtil.java deleted file mode 100644 index 23d6a023..00000000 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/MyMailUtil.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.jeecg.common.util; - -import cn.hutool.core.util.StrUtil; - -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import java.util.Date; -import java.util.Objects; - -public class MyMailUtil { - - private Integer port; - - public MyMailUtil(Integer port){ - this.port = port; - } - - /** - * 获取邮件主题 - * @param message - * @return - */ - public static String getSubject(Message message) throws MessagingException{ - String subject = null; - try { - subject = message.getSubject(); - } catch (MessagingException e) { - try { - subject = message.getHeader("subject")[0]; - } catch (MessagingException ex) { - throw new RuntimeException(ex); - } - } - return subject; - } - - public static Date getReceivedDate(Message message) throws MessagingException{ - Date receivedDate = null; - try { - receivedDate = message.getReceivedDate(); - } catch (MessagingException e) { - try { - receivedDate = new Date(message.getHeader("Date")[0]); - } catch (MessagingException ex) { - throw new RuntimeException(ex); - } - } - return receivedDate; - } - - public static String getMessageID(Message message) throws MessagingException{ - String messageId = ""; - try { - messageId = ((MimeMessage) message).getMessageID(); - } catch (MessagingException e) { - try { - messageId = Objects.isNull(message.getHeader("Message-ID")) ? "" : message.getHeader("Message-ID")[0]; - } catch (MessagingException ex) { - throw new RuntimeException(ex); - } - } - return messageId; - } - - public static String getAddress(Message message) throws MessagingException{ - String address = ""; - try { - address = ((InternetAddress) message.getFrom()[0]).getAddress(); - } catch (MessagingException e) { - try { - String[] froms = message.getHeader("From"); - if (null != froms) { - address = StrUtil.subBetween(froms[0], "<",">"); - } - } catch (MessagingException ex) { - throw new RuntimeException(ex); - } - } - return address; - } -}