Issue Details (XML | Word | Printable)

Key: JAMES-570
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Norman Maurer
Reporter: Norman Maurer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JAMES Server

James insert a Return-Path: null in outgoing email

Created: 19/Jul/06 09:54 AM   Updated: 21/Nov/07 08:31 AM
Return to search
Component/s: None
Affects Version/s: 2.3.0
Fix Version/s: 2.3.0

Time Tracking:
Not Specified

Issue Links:
Reference
 

Resolution Date: 19/Jul/06 08:14 PM


 Description  « Hide
At the moment james insert a Return-Path: null to outgoing emails. That is not correct. On outgoing emails no Return-Path should be insert.

From RFC (http://www.faqs.org/rfcs/rfc821.html):
When the receiver-SMTP makes the "final delivery" of a
message it inserts at the beginning of the mail data a
return path line. The return path line preserves the
information in the <reverse-path> from the MAIL command.
Here, final delivery means the message leaves the SMTP
world. Normally, this would mean it has been delivered to
the destination user, but in some cases it may be further
processed and transmitted by another mail system.


We have also to get sure what todo if there is allready one ( should never happen). Should we keep the header or strip it.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Soren Hilmer added a comment - 19/Jul/06 10:25 AM
The current SMTP specification is in (http://www.faqs.org/rfcs/rfc2821.html).

It has a lot more detail on this subject in section 4.4

Norman Maurer added a comment - 19/Jul/06 10:32 AM
Its also importent to know that some mailserver strip the return path if there is allready one and some not to reproduce this bug. For example postfix and sendmail seems to strip it. Qmail not.

Norman Maurer made changes - 19/Jul/06 11:23 AM
Field Original Value New Value
Assignee Norman Maurer [ norman ]
Stefano Bagnara added a comment - 19/Jul/06 02:33 PM
The problem seems to be related to code in MimeMessageWrapped added by Noel on 05/05/2005 (r168238)

"revision 109187 introduced a bug where if we had a real Return-Path header its value would not be the first in the String[]. This tries to eliminate that problem. We should still test to see if this hack is necessary at all, or if InternetHeaders.setHeader("Return-Path", <value>) is smart enough in JavaMail 1.3.2 to put the header at the top, instead of in the middle."

I this also the comment to r109187 is usefult:

Additional adjustments to fix JAMES-264. InternetHeaders is an awkward class to work with due its own internal handling of header order. This change takes advantage of how InternetHeaders works, pre-placing a null placeholder for a possible Return-Path header so that when setHeader is called, it will use that placeholder, and remove any other Return-Path headers. It also ensures that there are no other placeholders, providing a bit more control as we manipulate the Delivered-To headers (and possibly other headers that JavaMail may want to change internally, such as Message-ID, Date and Mime-Version).

InternetHeaders currently works differently if created with empty constructor or from stream. In the first case it create an empty sorted list of headers to keep positions, otherwise it does it the wrong way.

Changing the MailHeaders(InputStream) constructor to use the empty super constructor and calling load(is) seems to fix this difference.

Norman is currently working on writing unit testing and to find a solution to this issues.

Stefano Bagnara made changes - 19/Jul/06 02:34 PM
Link This issue is related to JAMES-264 [ JAMES-264 ]
Stefano Bagnara added a comment - 19/Jul/06 02:34 PM
This bug has been introduced by the fix to JAMES-264

Repository Revision Date User Message
ASF #423509 Wed Jul 19 16:05:41 UTC 2006 bago Correct (I hope) handling for the Return-Path header (JAMES-570, also related to JAMES-264)
Files Changed
ADD /james/server/trunk/src/test/org/apache/james/core/MailHeadersTest.java
MODIFY /james/server/trunk/src/test/org/apache/james/core/MimeMessageFromStreamTest.java
MODIFY /james/server/trunk/src/java/org/apache/james/core/MailHeaders.java
MODIFY /james/server/trunk/src/test/org/apache/james/core/MimeMessageWrapperTest.java
MODIFY /james/server/trunk/src/java/org/apache/james/core/MimeMessageWrapper.java
MODIFY /james/server/trunk/src/test/org/apache/james/core/MimeMessageTest.java

Stefano Bagnara added a comment - 19/Jul/06 04:10 PM
InternetHeaders have this bugs:
1) if you load an header from stream then following addHeader will not follow "default" sorting.
2) if you add a Return-Path to headers loaded from a stream with a Return-Path in the bad place it will add the new Return-Path just before the old one, and not at the start of the message
3) if you replace a Return-Path to headers loaded from a stream with a Return-Path in the bad place it will put the new Return-Path in the same position of the old one.

So we changed MailHeaders to fix this issues:
1) Changed the default constructor to use the right one from the super class and then load the stream
2) Changed the setHeader and addHeader to correctly handle the Return-Path header

Then we removed all the custom routine introduced by Noel to fix the Return-Path issues that had the problem described by this issue and was no more needed with this update.

This fix also allowed to remove workaround code from MimeMessageTest (it worked around the Return-Path: null). I probably have been too lazy inserting this workaround instead of trying to understand why it was there when testing.

Btw all the tests now passes, feel free to test it and backport to 2.3

Stefano Bagnara made changes - 19/Jul/06 04:10 PM
Fix Version/s 3.0 [ 10427 ]
Affects Version/s 2.3.0b3 [ 12311981 ]
Repository Revision Date User Message
ASF #423582 Wed Jul 19 20:09:29 UTC 2006 norman Backport fix for JAMES-570 ( also related to JAMES-264)
Files Changed
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/core/MimeMessageWrapper.java
MODIFY /james/server/branches/v2.3/src/java/org/apache/james/core/MailHeaders.java
MODIFY /james/server/branches/v2.3/src/test/org/apache/james/core/MimeMessageTest.java
MODIFY /james/server/branches/v2.3/src/test/org/apache/james/core/MimeMessageWrapperTest.java
ADD /james/server/branches/v2.3/src/test/org/apache/james/core/MailHeadersTest.java (from /james/server/trunk/src/test/org/apache/james/core/MailHeadersTest.java)

Repository Revision Date User Message
ASF #423584 Wed Jul 19 20:13:20 UTC 2006 norman Backport junit test (JAMES-570)
Files Changed
ADD /james/server/branches/v2.3/src/test/org/apache/james/core/MimeMessageFromStreamTest.java (from /james/server/trunk/src/test/org/apache/james/core/MimeMessageFromStreamTest.java)

Norman Maurer added a comment - 19/Jul/06 08:14 PM
Backported to 2.3

Norman Maurer made changes - 19/Jul/06 08:14 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Stefano Bagnara made changes - 21/Jul/06 03:37 PM
Fix Version/s 3.0 [ 10427 ]
Danny Angus added a comment - 21/Nov/07 08:31 AM
Closing issue fixed in released version.

Danny Angus made changes - 21/Nov/07 08:31 AM
Status Resolved [ 5 ] Closed [ 6 ]