在 Apache Commons Mail 中设置退回地址
使用 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。那么我怎样才能让它正常弹跳呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否使用数据包嗅探器检查过网络上实际传输的内容?如果 SMPT_HOST_NAME 上的 MSA 忽略并覆盖您的退回地址,我不会感到惊讶。
您可以尝试使用 MTA 的 SMTP 端口并快速检查这是否有影响。
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.
要设置退回地址,您可以在发送电子邮件之前使用 setBounceAddress(emailAddressString) 方法。
To set the bounce address you can make use of, setBounceAddress(emailAddressString) method before sending your email.