我尝试在电子邮件标题中添加一些与列表相关的标题行,但它不起作用..
msg.addHeader("List-ID", lmsg.getListId());
msg.addHeader("List-Archive", lmsg.getListId());
msg.setHeader("List-Post", lmsg.getListId());
msg.setHeader("List-Unsubscribe", lmsg.getListId());
msg.setHeader("X-Mailer", mailer);
msg.setSentDate(lmsg.getSendDate());
Transport.send(msg);
收到的邮件中没有任何列表标题行,但 x-mailer 行仍在其中...
我的错在哪里?
干杯
最佳答案
您的代码中没有明显的错误,因此您需要对其进行调试。开始here 。另外,在发送消息之前添加 msg.writeTo(new FileOutputStream("msg.txt"));然后检查 msg.txt 文件以确保它包含 header 。如果确实如此,并且它们仍然没有出现在收件人的邮箱中,则说明沿途的某些服务器正在删除它们。
关于JavaMail Api 列表标题不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21959235/