Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Rathan Chanti
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ron McLeod
Saloon Keeper
Posts: 1432
207
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!