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 Ian Huynh <ia...@hubspan.com> on 2003/05/20 02:33:29 UTC

Using James as relay connector?

Env: 
1. James 2.0a3 soon to upgrade to 2.1.3
2. Two Custom Mailets
3. 3 James Server


I have a requirements where depending on the recipient of the message, I need
to route the message to the correct Back End James Server running special mailets.

I have 3 servers, FRONT-END-JAMES-SERVER , and 2 BACK-END-JAMES-SERVER each
running custom mailets.  These mailets are very similar to each other except for 
some incompatible interfaces between version upgrade, and so therefore, they cannot live on the
same James Server (Which is why we are installing separate James Servers here)


  FRONT-END-JAMES-SERVER 
     - receives message
     - examines recipient
     - if recipient begins with PAID-CUSTOMER, route the message to BACK-END-JAMES-SERVER-01
     - else route message to BACK-END-JAMES-SERVER-02
         

Is this possible through Configuration ? 

Note 1: we aren't using any types of mailbox here.  All incoming mails are processed via mailets.
Note 2: MS Exchange has this concept and I am wondering if James supports this.

Thanks.


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


RE: Using James as relay connector?

Posted by "Noel J. Bergman" <no...@devtech.com>.
> I have developed the RecipientMatch matcher here is the code

Accepted.  Named changed to RecipientIsRegex, pending resolution of naming
convention discussion on james-dev.

I will also add your name to the "weare" page as a contributor.  Please note
that the James PMC voted to remove @author tags from the code base (lazy
removal - they are supposed to be deleted when the files are updated).

	--- Noel


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


Re: Using James as relay connector?

Posted by Cesar Bonadio <bo...@picture.com.br>.
Hello Ian

I am not 100% sure but I think this is possible but try this

Create 1 processor and send the message to the correct processor depending
of the name
for that you need a matcher that identifies tha message, I don't know if
james has one
but I developed.

<processor name="root">
         <mailet match=RecipientMatch=PAID-CUSTOMER(.*)@(.*)
class="ToProcessor">
            <processor> back1 </processor>
        </mailet>

         <mailet match=All class="ToProcessor">
            <processor> transport </processor>
        </mailet>
</processor>


 <processor name="back1">
         <mailet match="All" class="RemoteDelivery">
            <outgoing> file://var/mail/outgoing1 </outgoing>
            <delayTime> 21600000 </delayTime>
            <maxRetries> 5 </maxRetries>
            <deliveryThreads> 1 </deliveryThreads>
            <sendpartial>false</sendpartial>
            <gateway> BACK-END-JAMES-SERVER-01</gateway>
            <gatewayPort>25</gatewayPort>
         </mailet>
</processor>

 <processor name="transport">
         <mailet match="All" class="RemoteDelivery">
            <outgoing> file://var/mail/outgoing2 </outgoing>
            <delayTime> 21600000 </delayTime>
            <maxRetries> 5 </maxRetries>
            <deliveryThreads> 1 </deliveryThreads>
            <sendpartial>false</sendpartial>
            <gateway> BACK-END-JAMES-SERVER-02</gateway>
           <gatewayPort>25</gatewayPort>
         </mailet>
</processor>


I have developed the RecipientMatch matcher here is the code

/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software License
 * version 1.1, a copy of which has been included with this distribution in
 * the LICENSE file.
 */
package org.apache.james.transport.matchers;

import org.apache.mailet.GenericRecipientMatcher;
import org.apache.mailet.MailAddress;

import org.apache.oro.text.regex.*;

/**
 * Uses regular expression
 *
 *<p>&lt;mailet match=&quot;RecipientMatch=&lt;regular-expression&gt;&quot;
class=&quot;&lt;any-class&gt;&quot;&gt;</p>
 * <p>The example below will match any recipient in the format
user@log.anything</p>
 * <p>&lt;mailet match=&quot;RecipientMatch=(.*)@log\.(.*)&quot;
class=&quot;&lt;any-class&gt;&quot;&gt;<br>
 * &lt;/mailet&gt;<br>
 * </p>
 * @version 1.0.0, 27/06/2002
 * @author Cesar Bonadio <bo...@picture.com.br>
 */


public class RecipientMatch extends GenericRecipientMatcher {

   // Create Perl5Compiler and Perl5Matcher instances.
   Perl5Compiler compiler = new Perl5Compiler();
   Perl5Matcher matcher  = new Perl5Matcher();
   Pattern pattern   = null;


    public void init() throws javax.mail.MessagingException {
        try {
                pattern = compiler.compile( getCondition() );
        } catch(MalformedPatternException e) {
                e.printStackTrace();
        }
    }

    public boolean matchRecipient(MailAddress recipient) {
            String myRecipient = recipient.toString();
            if ( matcher.matches( myRecipient, pattern)  ){
                return true;
            } else {
                return false;
            }
    }
}






----- Original Message -----
From: "Ian Huynh" <ia...@hubspan.com>
To: <ja...@jakarta.apache.org>
Sent: Monday, May 19, 2003 9:33 PM
Subject: Using James as relay connector?


Env:
1. James 2.0a3 soon to upgrade to 2.1.3
2. Two Custom Mailets
3. 3 James Server


I have a requirements where depending on the recipient of the message, I
need
to route the message to the correct Back End James Server running special
mailets.

I have 3 servers, FRONT-END-JAMES-SERVER , and 2 BACK-END-JAMES-SERVER each
running custom mailets.  These mailets are very similar to each other except
for
some incompatible interfaces between version upgrade, and so therefore, they
cannot live on the
same James Server (Which is why we are installing separate James Servers
here)


  FRONT-END-JAMES-SERVER
     - receives message
     - examines recipient
     - if recipient begins with PAID-CUSTOMER, route the message to
BACK-END-JAMES-SERVER-01
     - else route message to BACK-END-JAMES-SERVER-02


Is this possible through Configuration ?

Note 1: we aren't using any types of mailbox here.  All incoming mails are
processed via mailets.
Note 2: MS Exchange has this concept and I am wondering if James supports
this.

Thanks.


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



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


RE: Using James as relay connector?

Posted by "Noel J. Bergman" <no...@devtech.com>.
> I have a requirements where depending on the recipient of the message,
> I need to route the message to the correct Back End James Server
> running special mailets.

See: http://nagoya.apache.org/wiki/apachewiki.cgi?James/SmartOrSecondaryHost

> - if recipient begins with PAID-CUSTOMER, route the message to
BACK-END-JAMES-SERVER-01
> - else route message to BACK-END-JAMES-SERVER-02

You would need a custom Matcher for that, because the current one doesn't do
prefix matching.  The one posted by Cesar should do the trick.

	--- Noel


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