Reputation: 57
https://github.com/bbottema/simple-java-mail
I'm using the Simple Java Mail library to send emails. How can I the override message-ID before sending my email?
Here is my code:
Mailer mailer = new Mailer(new ServerConfig(this.smtpHost, this.smtpPort,
this.from, this.password),TransportStrategy.SMTP_TLS, new
ProxyConfig(sockHost, sockPort));
mailer.trustAllSSLHosts(true);
mailer.sendMail(new EmailBuilder().from(this.user, this.from).to(to,
to).subject(this.subject).textHTML(this.body).build());
I desperately tried this after googling
Session session = mailer.getSession();
MimeMessage m = new testmm(session, "[email protected]");
m.saveChanges();
And here is the testmm
class code (copied from another topic here)
public class testmm extends MimeMessage {
private String messageID;
public testmm(Session session, String messageID) {
super(session);
this.messageID = messageID;
}
@Override
protected void updateMessageID() throws MessagingException {
setHeader("Message-ID", messageID);
}
}
Surely it doesn't work because I'm overriding another MimeMessage Object not the one used from this API. Has somebody found this issue before?
Upvotes: 1
Views: 690
Reputation: 11493
The Simple Java Mail documentation website actually describes overriding with custom Message-ID explicitly and it couldn't be simpler!
yourEmailBuilder.fixingMessageId("<123@456>");
Upvotes: 0