Forums Register Login

JavaMail API: Redirecting Bounced Emails is not working with mail.smtp.host

+Pie Number of slices to send: Send
Redirecting bounced email is not working for me even after I tried with various ports (587, 465, and 25 ), SMTP Servers (smtp.gmail.com, smtp.live.com, and smtp.mail.yahoo.com ), Message objects (MimeMessage, Message, and SMTPMessage), and JavaMail API methods (message.addFrom, message,setReplyTo, and message.setHeader). I also tried to change javax.mail jar versions 1.4, 1.5 and etc. Everywhere in the stackoverflow they are saying, setting the other email to mail.smtp.from should work. But all my bounced emails are going back to sender. Not to the specified email address. Can someone help me to redirect it to a new email address? Here is the code I am using
+Pie Number of slices to send: Send
This is not a JavaMail problem.  Although it may be in the RFCs that you can this, the reality is that Google/Microsoft/Yahoo are not going to let it happen.  They will simply overwrite what ever address you put in the Return-Path header with the address provided in the MAIL FROM.  Try sending messages through various providers and compare the headers sent with those received by the recipient.

Interestingly, I just tried sending an email with an alternate address in the From header through Gmail (which I do all the time with my home email server), and I found that Google overwrote it with the my MAIL FROM address, and added a X-Google-Original-From header with the From address that I provided.  

If you want to experiment a bit, set-up your own local test mail server (sendmail, exim, etc.) where you can define the policies, and see what behaviour setting the various headers causes.
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1442 times.
Similar Threads
How to set Return-Path to an email address other than Sender address using JavaMail?
com.sun.mail.util.MailLogger
Sending mail through Java
JavaMail TLS email
Unable to send an email from java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:49:19.