I have a working emailer service which normally send out email through a default address, lets say admin@mycomp.com
Now I am trying to add a return-path
in the email so whenever I receive an email I can directly reply to the sender email. Here's how I configure the properties:
private void sendOut() {
props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.from", "abc@google.com");
setJavaMailProperties(props);
Message message = new MimeMessage(getSession());
message.setFrom(new InternetAddress("admin@mycomp.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("admin@mycomp.com"));
message.setSubject("subject");
message.setText("content");
Transport.send(message);
}
However after sending out the email, I still see that the email is being sent out from my own email admin@mycomp.com
. I added the mail.smtp.from
based on the answer here How to set the Return-Path to an email address other than Sender address using JavaMail?. What did I miss here ?