How do I set Return-Path in JavaMail?

Posted on 2003-11-03
Last Modified: 2013-11-24
I have tried MimeMessage.setHeader("Return-Path","<" + returnPath + ">"); but it does not work.
JavaMail always sets the address of the sender as "Return-Path".

Question by:jerra
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 86

Expert Comment

ID: 9670794

Author Comment

ID: 9670895
Return-Path is not the same as Reply-To.
I thought they were the same at first but apparently not.

Return-Path is the address to where all errormessages is directed.
Reply-To the address used when user hits "Reply" in the mail client.

I am starting to believe it is not possible to change this in JavaMail.
LVL 86

Expert Comment

ID: 9670920
Ah I see. I would be very surprised if JavaMail does not allow this as they would not then have implemented the spec (unless it's a new addition)
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.


Author Comment

ID: 9670954
RFC 2821
"When the delivery SMTP server makes the "final delivery" of a
   message, it inserts a return-path line at the beginning of the mail
   data.  This use of return-path is required; mail systems MUST support

My mistake, apparently it is not up to the client to set this.
LVL 86

Accepted Solution

CEHJ earned 100 total points
ID: 9671002
Yes. This would suggest using my first post *is* the way to go:

The Return-Path header is always added by the final delivery agent, and it's
based on the envelope sender address. What you need to do is have your Java
mail program set the correct envelope sender address (this is the address
specified in the SMTP MAIL FROM command). Most MUA's automatically set the
envelope sender address to be the same as the address in the From header unless
you specify something else.

Author Comment

ID: 9671024
Yes you're right, as always...  (;

LVL 86

Expert Comment

ID: 9671047

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 52
servlet filter example 37 85
eclipse apache tomcat admin console 52 156
Java exception bubble up 2 24
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question