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("[email protected]");
email.setMsg("Hello");
email.setFrom("[email protected]");
email.addReplyTo("[email protected]");
email.addTo("[email protected]");
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?