You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Ted Watson <tw...@mindbridge.com> on 2004/09/16 19:30:13 UTC

Problem bouncing email to sender

I'm trying to write a mailet to bounce mail back to the sender in the event that an email is received for an unknown user on my host.  This is my service function, which works except for the bounce:

    public void service(Mail mail) throws MessagingException
    {
            mc=getMailetContext();
            Collection recipients=mail.getRecipients();
            Iterator it = recipients.iterator();
  
            MailAddress testAddr = null;       
            while(it.hasNext())
            {
                testAddr = (MailAddress)it.next();
                if(!mc.isLocalUser(testAddr.getUser()))
               {
                System.out.println("Bad Local User Found, notifying sender");
                mc.bounce(mail,"Returned Mail");
               }
           }
   } 

The config file has the line:

<mailet match="All" class "BounceIt"/>

Why won't this bounce anything back to the sender?  Thanks.