• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic