diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java index 1b01d28f..17459d34 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/Mail.java @@ -18,10 +18,7 @@ import jakarta.mail.internet.MimeMultipart; import jakarta.mail.internet.MimeUtility; import jakarta.mail.util.ByteArrayDataSource; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; +import java.io.*; import java.nio.charset.Charset; import java.util.Date; @@ -32,7 +29,8 @@ import java.util.Date; * @since 3.2.0 */ public class Mail implements Builder { - private static final long serialVersionUID = 1L; + @Serial + private static final long serialVersionUID = 1L; /** * 邮箱帐户信息以及一些客户端配置信息 @@ -261,7 +259,7 @@ public class Mail implements Builder { bodyPart.setDataHandler(new DataHandler(attachment)); nameEncoded = attachment.getName(); if (this.mailAccount.isEncodefilename()) { - nameEncoded = org.dromara.common.mail.utils.InternalMailUtil.encodeText(nameEncoded, charset); + nameEncoded = InternalMailUtil.encodeText(nameEncoded, charset); } // 普通附件文件名 bodyPart.setFileName(nameEncoded); @@ -423,7 +421,7 @@ public class Mail implements Builder { // 用户未提供发送方,则从Session中自动获取 msg.setFrom(); } else { - msg.setFrom(org.dromara.common.mail.utils.InternalMailUtil.parseFirstAddress(from, charset)); + msg.setFrom(InternalMailUtil.parseFirstAddress(from, charset)); } // 标题 msg.setSubject(this.title, (null == charset) ? null : charset.name()); @@ -432,14 +430,14 @@ public class Mail implements Builder { // 内容和附件 msg.setContent(buildContent(charset)); // 收件人 - msg.setRecipients(MimeMessage.RecipientType.TO, org.dromara.common.mail.utils.InternalMailUtil.parseAddressFromStrs(this.tos, charset)); + msg.setRecipients(MimeMessage.RecipientType.TO, InternalMailUtil.parseAddressFromStrs(this.tos, charset)); // 抄送人 if (ArrayUtil.isNotEmpty(this.ccs)) { - msg.setRecipients(MimeMessage.RecipientType.CC, org.dromara.common.mail.utils.InternalMailUtil.parseAddressFromStrs(this.ccs, charset)); + msg.setRecipients(MimeMessage.RecipientType.CC, InternalMailUtil.parseAddressFromStrs(this.ccs, charset)); } // 密送人 if (ArrayUtil.isNotEmpty(this.bccs)) { - msg.setRecipients(MimeMessage.RecipientType.BCC, org.dromara.common.mail.utils.InternalMailUtil.parseAddressFromStrs(this.bccs, charset)); + msg.setRecipients(MimeMessage.RecipientType.BCC, InternalMailUtil.parseAddressFromStrs(this.bccs, charset)); } // 回复地址(reply-to) if (ArrayUtil.isNotEmpty(this.reply)) { diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java index 5492bd2e..d2b9e2c0 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailAccount.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.setting.Setting; +import java.io.Serial; import java.io.Serializable; import java.nio.charset.Charset; import java.util.HashMap; @@ -17,7 +18,8 @@ import java.util.Properties; * @author Luxiaolei */ public class MailAccount implements Serializable { - private static final long serialVersionUID = -6937313421815719204L; + @Serial + private static final long serialVersionUID = -6937313421815719204L; private static final String MAIL_PROTOCOL = "mail.transport.protocol"; private static final String SMTP_HOST = "mail.smtp.host"; diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java index 82e65099..ced09a29 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailException.java @@ -3,12 +3,15 @@ package org.dromara.common.mail.utils; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.StrUtil; +import java.io.Serial; + /** * 邮件异常 * @author xiaoleilu */ public class MailException extends RuntimeException{ - private static final long serialVersionUID = 8247610319171014183L; + @Serial + private static final long serialVersionUID = 8247610319171014183L; public MailException(Throwable e) { super(ExceptionUtil.getMessage(e), e); diff --git a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java index 023be86a..0400700b 100644 --- a/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java +++ b/ruoyi-common/ruoyi-common-mail/src/main/java/org/dromara/common/mail/utils/MailUtils.java @@ -413,7 +413,7 @@ public class MailUtils { */ private static String send(MailAccount mailAccount, boolean useGlobalSession, Collection tos, Collection ccs, Collection bccs, String subject, String content, Map imageMap, boolean isHtml, File... files) { - final org.dromara.common.mail.utils.Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession); + final Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession); // 可选抄送人 if (CollUtil.isNotEmpty(ccs)) {