You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mailet-api@james.apache.org by "Eric Charles (JIRA)" <ma...@james.apache.org> on 2012/12/21 08:31:26 UTC

[jira] [Commented] (MAILET-85) Resend mailet mistakenly treats SpecialAddress.RECIPIENTS as SpecialAddress.TO

    [ https://issues.apache.org/jira/browse/MAILET-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13537727#comment-13537727 ] 

Eric Charles commented on MAILET-85:
------------------------------------

Hi Adrian,

I understand you encountered a problem using the Resend mailet. Can you detail that problem?

Also, you fix something in the AbstractRedirect class, which is extended also by Forward, Redirect... How are you sure there will be no impact to these mailets?

Thx, Eric


                
> Resend mailet mistakenly treats SpecialAddress.RECIPIENTS as SpecialAddress.TO
> ------------------------------------------------------------------------------
>
>                 Key: MAILET-85
>                 URL: https://issues.apache.org/jira/browse/MAILET-85
>             Project: James Mailet
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Adrian Baker
>
> In org.apache.james.transport.mailets.AbstractRedirect#replaceInternetAddresses(Mail, Collection), this code block means that using the "recipients" special adresses in the Resend mailet config incorrectly gives you the TO addresses:
> } else if (internetAddress.equals(SpecialAddress.TO.toInternetAddress()) || internetAddress.equals(SpecialAddress.RECIPIENTS.toInternetAddress())) {
> 		try {
> 				String[] toHeaders = mail.getMessage().getHeader(RFC2822Headers.TO);
> 				if (toHeaders != null) {
> 						for (int i = 0; i < toHeaders.length; i++) {
> 								try {
> 										InternetAddress[] originalToInternetAddresses = InternetAddress.parse(toHeaders[i], false);
> 										for (int j = 0; j < originalToInternetAddresses.length; j++) {
> 												newList.add(originalToInternetAddresses[j]);
> 										}
> The fix is straightforward:
> } else if (internetAddress.equals(SpecialAddress.TO.toInternetAddress())) {
> 	...
> } else if (internetAddress.equals(SpecialAddress.RECIPIENTS.toInternetAddress())) {
> 	if(mail.getRecipients() != null) {
> 		for(Object recipient : mail.getRecipients()) {
> 			newList.add(((MailAddress)recipient).toInternetAddress());
> 		}
> 	}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira