gpt4 book ai didi

JavaMail BASE64_LENGTH_79_INF 垃圾邮件

转载 作者:行者123 更新时间:2023-12-01 16:40:56 24 4
gpt4 key购买 nike

当我尝试通过 javamail api 发送电子邮件时,收件人的邮件会变成垃圾邮件。原因是 BASE64_LENGTH_79_INFMIME_HTML_ONLY

public void sendEmail(String to, String subject, String body, File filename ) {
String Host = "ip";

java.util.Properties props = new java.util.Properties();
props.put("mail.smtp.host", Host);

javax.mail.Session mailSession = javax.mail.Session.getDefaultInstance(props, null);
mailSession.setDebug(true);
MimeMessage message = new MimeMessage(mailSession);
try {
message.setFrom(new InternetAddress("some@email"));
InternetAddress[] address = {new InternetAddress(to)};
message.setRecipients(Message.RecipientType.TO, address);
message.setSubject(subject);



BodyPart messageBodyPart = new MimeBodyPart();

// Now set the actual message
messageBodyPart.setContent(body, "text/html; charset=utf-8");

// Create a multipar message
Multipart multipart = new MimeMultipart();

// Set text message part
multipart.addBodyPart(messageBodyPart);

// Part two is attachment
messageBodyPart = new MimeBodyPart();

DataSource source = new FileDataSource(filename);

messageBodyPart.setDataHandler(new DataHandler(source));
System.out.println("-----------------------------------");
System.out.println(filename.getName());
messageBodyPart.setFileName(filename.getName());
multipart.addBodyPart(messageBodyPart);

// Send the complete message parts
message.setContent(multipart);

// Send message
Transport.send(message);

System.out.println("Sent message successfully....");

} catch (MessagingException ex) {
ex.printStackTrace();
}

有办法解决这个问题吗?

谢谢

最佳答案

MIME_HTML_ONLY 包含在:I want to send HTML emails from my site, but Outlook is flagging them as spam

如果您对邮件正文部分进行 Base64 编码,JavaMail 将使用 default of 76 bytes per line 。在附加邮件正文部分之前,请尝试对其进行 Base64 编码。

关于JavaMail BASE64_LENGTH_79_INF 垃圾邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61865455/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com