How to set the Return-Path to an email address other than Sender address using JavaMail?
How to set the Return-Path to an email address other than Sender address using JavaMail?
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).