Thanks a lot,
Just for reference, if someone else is looking to send emails from Java via SMTP, use com.sun.mail.smtp.SMTPMess
Main Topics
Browse All TopicsWe use Postfix to send emails from Java (Tomcat). We want to give each outgoing message a unique Return-Path header, so that our system automatically can register bounced email addresses.
For example, when I send an email to test@somewhere.com I want to use a Return-Path as 1234-ieh9fj83oiu@bounce.my
I set the unique Return-Path header in the email in Java, before passing it on to Postfix through an SMTP connection. I have logged the outgoing message, and it has the correct (unique) "Return-Path" address.
However, when the email arrives to the recipient the Return-Path is set as support@mydomain.com. This is the email address used in From. It seems that Postfix automatically resets our custom Return-Path header with the From header.
I believe this is in line with the SMTP guidelines, when an SMTP server gateway sends an email it should reset the Return-Path header.
How can I configure Postfix so that it does NOT change the Return-Path header for my own emails?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: kevin_uPosted on 2009-07-18 at 14:56:14ID: 24887482
Return path is something that the MTA (in your case postfix) will always replace with whatever it received in the MAIL FROM: during the SMTP exchange, and not what the headers say.
So can you Java smtp api actually specify the from address (the "envelope from", not the "From:" header)? Your trick is to put your code into the api in a way that makes it put that into MAIL FROM: during the smtp conversation.
The from in the mail headers aren't used (sometimes they are adjusted) by the MTA.
You might also try adding a X-Errors-To: and Reply-To: headers. Some MTA's will use them.