我正在使用org.springframework.mail.javamail.JavaMailSender
SMTP 发送电子邮件,并且我需要检索 Message-ID 标头。下面的代码
message.getMimeMessage().getMessageID()
正在返回 null。如何检索消息 ID?
public void notifyByMail(final NotificationRequest request)
{
MimeMessagePreparator preparator = new MimeMessagePreparator()
{
public void prepare(MimeMessage mimeMessage) throws Exception
{
MimeMessageHelper message = null;
message = new MimeMessageHelper(mimeMessage, UTF_8);
message.setTo(request.getTo());
message.setCc(request.getCc());
message.setFrom(request.getFrom());
message.setReplyTo(request.getReplyTo());
message.setSubject(request.getSubject());
message.setText("some text", true);
//Need to retrieve the Message-ID here
System.out.println("Message - ID : " + message.getMimeMessage().getMessageID());
}
};
getMailSender().send(preparator);
}