使用Apache Commons發送電子郵件的代碼如下。在Apache Commons郵件中設置退回地址
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();
但是反彈是行不通的。它將反彈發送給驗證郵件的一方,在本例中爲SMTP_AUTH_USER。那麼我怎樣才能讓它正常彈跳呢?
這似乎是使用Gmail作爲提供者的問題。 – Milhous