[ 
https://issues.apache.org/jira/browse/JAMES-882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12658158#action_12658158
 ] 

Robert Burrell Donkin commented on JAMES-882:
---------------------------------------------

I'm a little confused. Can anyone explain how the follow code set new local 
recipients?

public abstract class AbstractVirtualUserTableMailet extends GenericMailet {
    
    /*
     * (non-Javadoc)
     * @see org.apache.mailet.base.GenericMailet#service(org.apache.mailet.Mail)
     */
    public void service(Mail mail) throws MessagingException {
        Collection recipients = mail.getRecipients();
        Collection errors = new Vector();

        MimeMessage message = mail.getMessage();

        // Set Return-Path and remove all other Return-Path headers from the
        // message
        // This only works because there is a placeholder inserted by
        // MimeMessageWrapper
        message
                .setHeader(RFC2822Headers.RETURN_PATH,
                        (mail.getSender() == null ? "<>" : "<"
                                + mail.getSender() + ">"));

        Collection newRecipients = new LinkedList();
        for (Iterator i = recipients.iterator(); i.hasNext();) {
            MailAddress recipient = (MailAddress) i.next();
            try {
                Collection usernames = processMail(mail.getSender(), recipient,
                        message);

                // if the username is null or changed we remove it from the
                // remaining recipients
                if (usernames == null) {
                    i.remove();
                } else {
                    i.remove();
                    // if the username has been changed we add a new recipient
                    // with the new name.
                    newRecipients.addAll(usernames);
                }

            } catch (Exception ex) {
                getMailetContext().log("Error while storing mail.", ex);
                errors.add(recipient);
            }
        }

        if (newRecipients.size() > 0) {
            recipients.addAll(newRecipients);
        }

        if (!errors.isEmpty()) {
            // If there were errors, we redirect the email to the ERROR
            // processor.
            // In order for this server to meet the requirements of the SMTP
            // specification, mails on the ERROR processor must be returned to
            // the sender. Note that this email doesn't include any details
            // regarding the details of the failure(s).
            // In the future we may wish to address this.
            getMailetContext().sendMail(mail.getSender(), errors, message,
                    Mail.ERROR);
        }

        if (recipients.size() == 0) {
            // We always consume this message
            mail.setState(Mail.GHOST);
        }

> VirtualUserTable-Store is not working anymore
> ---------------------------------------------
>
>                 Key: JAMES-882
>                 URL: https://issues.apache.org/jira/browse/JAMES-882
>             Project: JAMES Server
>          Issue Type: Bug
>    Affects Versions: 3.0, Trunk
>            Reporter: Norman Maurer
>            Assignee: Norman Maurer
>             Fix For: 3.0
>
>         Attachments: diff.txt, vut-smoke.patch, vut-support.diff
>
>
> In current trunk the VirtualUserTable-Store implementation get never called 
> from a mailet to rewrite recipients.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to