修改发邮件功能

This commit is contained in:
qitz
2023-10-27 09:57:41 +08:00
parent b5c2bb391c
commit 8c950a2fd1
5 changed files with 54 additions and 21 deletions
@@ -95,6 +95,9 @@ public class EmailOutUtil {
*/
public void sendEmil(String to, String message, String subject, List<File> fileList, File file) {
try {
String messageContent = "<html><body><p style=\"font-family: Arial, sans-serif; font-size: 18px;\">"+message+"。</p></body></html>";
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(messageContent, "text/html;charset=utf-8");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
//设置邮件会话参数
@@ -125,13 +128,14 @@ public class EmailOutUtil {
//设置邮件消息
msg.setSubject(subject);
msg.setText(message);
msg.setDescription("messageutf-8html");
//设置发送的日期
msg.setSentDate(new Date());
// 创建邮件正文
MimeMultipart multipart = new MimeMultipart();
// MimeBodyPart bodyPart = new MimeBodyPart();
// bodyPart.setContent("This is the body of the email", "text/html");
// multipart.addBodyPart(bodyPart);
multipart.addBodyPart(messageBodyPart);
// 添加附件
if (file != null) {
MimeBodyPart attachmentPart = new MimeBodyPart();