Alright.  It appears I'm smacking to myself today but if there's anyone out 
there actually listening on this list I could definitely use your help.  I'm 
almost there with my first mailet but for some reason I'm running into a snag.  
What I want to do is replace the recipients of the original email with a 
completely new list of recipients.  I did a lot of searching in the archives 
and came up with the solution below.  The problem is that the recipient isn't 
getting changed even though I followed the instructions here:

http://tinyurl.com/4kh6q

I found other solutions which involved subclassing AbstractRedirect and 
overriding getRecipients() but that didn't seem to work.  Any and all help 
would be awesome.

Thanks,
Ricardo

PS:  My code is below.

Mailet Entry in the root processor:
==================================

<mailet match="HasHeader=X-Bolt-Notes-Receiver" class="ToProcessor">
    <processor>bolt</processor>
</mailet>

My Custom Processor:
===================

      <processor name="bolt">
          <mailet match="HasHeader=X-Bolt-Notes-Receiver" 
class="com.bolt.james.BoltMailet"/>

          <mailet match="RemoteAddrNotInNetwork=127.0.0.1, 209.208.135.187" 
class="ToProcessor">
             <processor> relay-denied </processor>
             <notice>550 - Requested action not taken: relaying denied</notice>
          </mailet>

          <!-- Attempt remote delivery using the specified repository for the 
spool, -->
          <!-- using delay time to retry delivery and the maximum number of 
retries -->
          <mailet match="All" class="RemoteDelivery">
             <outgoing> file://var/mail/outgoing/ </outgoing>
             <!-- alternative database repository example below -->
             <!--
             <outgoing> db://maildb/spool/outgoing </outgoing>
             -->

             <!-- Delivery Schedule based upon RFC 2821, 4.5.4.1 -->
             <!-- 5 day retry period, with 4 attempts in the first
                  hour, two more within the first 6 hours, and then
                  every 6 hours for the rest of the period. -->
             <!--
          <delayTime>  5 minutes </delayTime>
          <delayTime> 10 minutes </delayTime>
          <delayTime> 45 minutes </delayTime>
          <delayTime>  2 hours </delayTime>
          <delayTime>  3 hours </delayTime>
              <delayTime>  6 hours </delayTime>
             -->
             <delayTime>  2 minutes </delayTime>
             <delayTime>  5 minutes </delayTime>
             <delayTime> 15 minutes </delayTime>
             <delayTime>  30 minutes </delayTime>
             <delayTime>  1 hour </delayTime>
             <delayTime>  3 hours </delayTime>
             <maxRetries> 25 </maxRetries>

             <!-- The number of threads that should be trying to deliver 
outgoing messages -->
             <deliveryThreads> 5 </deliveryThreads>

             <!-- If false the message will not be sent to given server if any 
recipients fail -->
             <sendpartial>false</sendpartial>

             <!-- A single mail server to deliver all outgoing messages. -->
             <!-- This is useful if this server is a backup or failover 
machine, -->
             <!-- or if you want all messages to be routed through a particular 
mail server, -->
             <!-- regardless of the email addresses specified in the message -->
             <!-- -->
             <!-- The gateway element specifies the gateway SMTP server name. 
-->
             <!-- If your gateway mail server is listening on a port other than 
25, -->
             <!-- you can set James to connect to it on that port using the 
gatewayPort -->
             <!-- element. -->
             <!-- Although normally multiple addresses are implemented through 
proper -->
             <!-- DNS configuration, the RemoteDelivery mail does allow 
specifying -->
             <!-- multiple gateway elements, each of which may also have a port 
-->
             <!-- e.g., mygateway:2525 -->
             <!-- the gatewayPort element is used as a default -->
             <!--
             <gateway> otherserver.mydomain.com </gateway>
             <gatewayPort>25</gatewayPort>
             -->
          </mailet>

      </processor>

The Custom Mailet:
==================

* Note that I'm not trying to change all the recipients yet, just one for now 
to get everything working.

public class BoltMailet extends GenericMailet {

    public void service(Mail originalMail) throws MessagingException {
        Collection recipients = originalMail.getRecipients();
        for (Iterator iter = recipients.iterator();iter.hasNext();) {
            MailAddress aMailAddress = (MailAddress)iter.next();
            System.out.println("aMailAddress:  "+aMailAddress);
        }
        recipients.clear();
        recipients.add(new MailAddress("[EMAIL PROTECTED]"));

        for (Iterator iter = recipients.iterator();iter.hasNext();) {
            MailAddress newMailAddress = (MailAddress)iter.next();
            System.out.println("newMailAddress:  "+newMailAddress);
        }
        
    }
}




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

Reply via email to