4

Using the Apache Commons to send email there is the following code.

HtmlEmail email = new HtmlEmail();
email.setHostName(SMTP_HOST_NAME);
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator(SMTP_AUTH_USER, SMTP_AUTH_PWD));
email.setTLS(true);
email.setBounceAddress("aaa@abc.com");
email.setMsg("Hello");
email.setFrom("bbb@abc.edu");
email.addReplyTo("bbb@abc.edu");
email.addTo("i.do.not.exist@abc.gmail.com");
email.send();

But the bounce will not work. It sends the bounce to the party that authenticated the message, which in this example is SMTP_AUTH_USER. So How can I get it to bounce properly?

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
Milhous
  • 14,473
  • 16
  • 63
  • 82

2 Answers2

2

Did you check with a packet sniffer what is actually going over the wire? I wouldn't be surprised if the MSA on SMPT_HOST_NAME ignores and overrides your bounce address.

You could try using the SMTP-port to the MTA and quickly check if this makes a difference.

Volker Stolz
  • 7,274
  • 1
  • 32
  • 50
0

To set the bounce address you can make use of, setBounceAddress(emailAddressString) method before sending your email.

mukulSharma
  • 113
  • 2
  • 6