How to set the Return-Path to an email address other than Sender address using JavaMail?

Viewed 21511

How to set the Return-Path to an email address other than Sender address using JavaMail?

3 Answers

I found that if the 'mail.protocol' property is set to something other than 'smtp' (like 'smtps'), then only the following would work:

props.put("mail.smtps.from", "replyto@example.com");

This allowed me to avoid using the SMTPMessage class as described in GiorgosDev's answer (classes in the 'com.sun' package aren't intended to be public API).

Related