You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Neill Robbins <ne...@phocis.com> on 2003/11/26 01:24:06 UTC

LOTS of MimeMessageWrapper issues... bugs?

Excuse posting to both user and developer, but I thought this issue was possibly serious enough to warrant both...

I am using James 2.1.3

I have written a mailet in which I am trying to filter a subset of the recipents of a MimeMessage so that they can be processed differently from the rest.

The problem I have is that the MimeMessage I get from James is wrapped in a MimeMessageWrapper which appears to be causing me no end of trouble. 

Consider the following.  I have a couple of filters that match an incoming mimeMessage.  The MimeMessgae has 5 recipients.  The first filter in my mailet is intended to catch 2 recipients, and when it does so, it should strip those recipents off the message.  The second filter then receives the message with the remaining 3 recipients.  It strips off another 2, and the final message as one recipient and is processed normally.

The idea is that the filters can be applied to the mail to transform the mail for the specified recipients into a request to another system.

OK.  To do this I am making calls to MimeMessage.getRecipents(RecipentType), working out recipients match, and then calling MimeMessage.setRecipents(RecipentType, remainingAddresses) to decrease the number of recipients for the next filter.

I have had a look at the source for MimeMessageWrapper, and what appears to be happening is that may call to MimeMessage.setRecipents(RecipentType, remainingAddresses) works OK, but when I then call MimeMessage.getRecipents(RecipentType) for the second filter, the recipient list is unchanged. 

It appears MimeMessage.setRecipents(RecipentType, remainingAddresses) does NOT update its cached headers, so subsequent calls to getRecipients are incorrect.  
This is not true for specific some header manipulation functions (e.g setSubject, where the cached headers and the message headers are both updated.

The public functions that from a quick look do not appear to update the in memory cache of the headers, and therefore probably need attention are:

addRecipients
setContentId
setContentMD5
setFrom 
setRecipients
setReplyTo

The following look like they are probably OK, as they update the header cache:

setSubject
setSentDate

The following are also OK because the gets read from the cached message not the cached header:

setContentLanguage
setDescription
setDisposition
setFileName
setFlags


Also, getSize and getMessageSize appears to return the size of the original message, not the size of the cached message, which may well have changed.  I don't know what this is being used for, so I don't know whether it is a problem or not

Have I got this totally wrong, or is there a serious set of bugs here?

Thanks in advance
N


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: LOTS of MimeMessageWrapper issues... bugs?

Posted by Serge Knystautas <se...@lokitech.com>.
> Have I got this totally wrong, or is there a serious set of bugs here?

Unfortunately it's the former.

You shouldn't be touching the MimeMessage if you want to change the 
recipient list.  You want to edit the Collection of MailAddress objects 
available from the Mail object.

If you think of it this way, the MimeMessage is the actual email 
message, which you wouldn't want to be changing... you don't want to 
add/remove To: Cc: headers to the message.  The Mail object contains 
both the MimeMessage that we're delivering and the recipients of that 
message.

-- 
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org