Hello

I posted about this problem a while ago on the user list (as I am
a James user, not a developer), but didn't get much response. This
time, I'm including a patch; I hope that someone will pick it up.

We are experiencing some unexpected behavior with James 2.1.3 when
sending a message that has two Return-Path headers.

An example of such a message:

    Return-Path: [EMAIL PROTECTED]
    From: "Brinkers" <[EMAIL PROTECTED]>
    To: <[EMAIL PROTECTED]>
    Subject: Return-Path mail
    Return-Path: [EMAIL PROTECTED]
    Date: Tue, 9 Dec 2003 22:36:33 -0500

    Hoi

James transforms this into something like

    Content-Type: text/plain;
     charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    content-class: urn:content-classes:message
    Subject:
    Date: Thu, 15 Jan 2004 12:02:16 +0100

    [EMAIL PROTECTED]
    Received: from vallum.intra.izecom.com ([192.168.0.1])
              by uffizi.intra.izecom.com (JAMES SMTP Server 2.1.3)
with SMTP
    ID 302
              for <[EMAIL PROTECTED]>;
              Thu, 15 Jan 2004 12:02:19 +0100 (CET)
    From: "Brinkers" <[EMAIL PROTECTED]>
    To: <[EMAIL PROTECTED]>
    Subject: Test Mail
    Date: Tue, 9 Dec 2003 22:36:33 -0500

    Hoi

It seems that new headers are created and the original headers
start with
after a blank line, causing them to be interpreted as a message
body.

In Outlook, this is displayed as a message without Subject or From
field,
where the message body starts with the
'[EMAIL PROTECTED]' followed by
the original headers.

Now putting the Return-Path twice in your headers is probably not
a good
idea, but we do happen to have some emails that have that in our
test set
and would like to process them in a reasonable way.


So we investigated the James source code trying to find the cause
for this
unexpected behavior.

In org.apache.james.smtpserver.SMTPHandler in the method
processMailHeaders() we found the following call to retrieve the
Return-Path
header.

        // Determine the Return-Path
        String returnPath =
headers.getHeader(RFC2822Headers.RETURN_PATH,
"\r\n");

This roughly means "Give me all Return-Path headers separated by
line
breaks.". Later on, this returnPath String is put on top of all
headers.
We deduced that if there is more than one Return-Path header, this
will
result in something like

    Return-Path: [EMAIL PROTECTED]
    [EMAIL PROTECTED]
    From: "Brinkers" <[EMAIL PROTECTED]>
    To: <[EMAIL PROTECTED]>
    Subject: Return-Path mail
    Date: Tue, 9 Dec 2003 22:36:33 -0500

    Hoi

where that the second line ('[EMAIL PROTECTED]') is
interpreted as the start of the message body later on, causing new
headers to be invented and
the old headers to dispappear on the message body.

We changed the call to get the getHeader() in processMailHeaders()
to pass a
null argument:

        // Determine the Return-Path
        String returnPath =
headers.getHeader(RFC2822Headers.RETURN_PATH, null);

which roughly means "Give only one Return-Path header".

After recompiling and deploying James, our test mails passed James
correctly.

We would appreciate it if this fix, or a similar one, could be
included in
the next James release. The patch is attached.

Thank you

    Hes Siemelink
    Izecom BV
RCS file: 
/home/cvspublic/james-server/src/java/org/apache/james/smtpserver/SMTPHandler.java,v
retrieving revision 1.55
diff -u -r1.55 SMTPHandler.java
--- SMTPHandler.java    21 Feb 2004 23:15:31 -0000      1.55
+++ SMTPHandler.java    30 Mar 2004 13:12:20 -0000
@@ -178,7 +178,7 @@
      * The mail attribute holding the SMTP AUTH user name, if any.
      */
     private final static String SMTP_AUTH_USER_ATTRIBUTE_NAME = 
"org.apache.james.SMTPAuthUser";
-    
+
     /**
      * The thread executing this handler
      */
@@ -580,7 +580,7 @@
     private boolean parseCommand(String command) throws Exception {
         String argument = null;
         boolean returnValue = true;
-        
+
 
         if (command == null) {
             return false;
@@ -1324,7 +1324,7 @@
             headers.setHeader(RFC2822Headers.FROM, state.get(SENDER).toString());
         }
         // Determine the Return-Path
-        String returnPath = headers.getHeader(RFC2822Headers.RETURN_PATH, "\r\n");
+        String returnPath = headers.getHeader(RFC2822Headers.RETURN_PATH, null);
         headers.removeHeader(RFC2822Headers.RETURN_PATH);
         StringBuffer headerLineBuffer = new StringBuffer(512);
         if (returnPath == null) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to