From ecd9a47fb8b05dfd11dfafea5d5462c0e5704872 Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Thu, 21 Dec 2017 21:08:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0RM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xxl/job/admin/core/util/MailUtil.java | 65 ------------------- 1 file changed, 65 deletions(-) diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/MailUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/MailUtil.java index c37a9295..8c7733b5 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/MailUtil.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/MailUtil.java @@ -3,12 +3,10 @@ package com.xxl.job.admin.core.util; import org.apache.commons.lang.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.mail.javamail.MimeMessageHelper; import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeUtility; import java.io.File; import java.util.Properties; import java.util.concurrent.ExecutorService; @@ -33,70 +31,7 @@ public class MailUtil { password = PropertiesUtil.getString("xxl.job.mail.password"); sendNick = PropertiesUtil.getString("xxl.job.mail.sendNick"); } - - /** - - - - - - - - - true - true - - - - - */ - /** - * 发送邮件 (完整版)(结合Spring) - * - * //@param javaMailSender: 发送Bean - * //@param sendFrom : 发送人邮箱 - * //@param sendNick : 发送人昵称 - * @param toAddress : 收件人邮箱 - * @param mailSubject : 邮件主题 - * @param mailBody : 邮件正文 - * @param mailBodyIsHtml: 邮件正文格式,true:HTML格式;false:文本格式 - * @param attachments : 附件 - */ - @SuppressWarnings("null") - public static boolean sendMailSpring(String toAddress, String mailSubject, String mailBody, boolean mailBodyIsHtml,File[] attachments) { - JavaMailSender javaMailSender = null;//ResourceBundle.getInstance().getJavaMailSender(); - try { - MimeMessage mimeMessage = javaMailSender.createMimeMessage(); - MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, ArrayUtils.isNotEmpty(attachments), "UTF-8"); // 设置utf-8或GBK编码,否则邮件会有乱码;multipart,true表示文件上传 - - - helper.setFrom(username, sendNick); - helper.setTo(toAddress); - - // 设置收件人抄送的名片和地址(相当于群发了) - //helper.setCc(InternetAddress.parse(MimeUtility.encodeText("邮箱001") + " <@163.com>," + MimeUtility.encodeText("邮箱002") + " <@foxmail.com>")); - helper.setSubject(mailSubject); - helper.setText(mailBody, mailBodyIsHtml); - - // 添加附件 - if (ArrayUtils.isNotEmpty(attachments)) { - for (File file : attachments) { - helper.addAttachment(MimeUtility.encodeText(file.getName()), file); - } - } - - // 群发 - //MimeMessage[] mailMessages = { mimeMessage }; - - javaMailSender.send(mimeMessage); - return true; - } catch (Exception e) { - logger.error(e.getMessage(), e); - } - return false; - } - /** * 发送邮件 (完整版) (纯JavaMail) *