Hi Gary,

now it gets a little bit complicated ;-P ..

You could write your own James class which extends
org.apache.james.James and your own Matcher to match wildcard domains.
After this you need to modify assembly.xml to load your james class.
Maybe this sounds a bit complex. Let me show you some code snippets to
explain:

1. Create a new James class which extends org.apache.james.James:
--------------------------------------------------------------------

package org.apache.james;

import java.util.ArrayList;

import java.util.List;

import java.util.Locale;

import org.apache.avalon.framework.configuration.Configuration;

import org.apache.avalon.framework.configuration.ConfigurationException;

public class MyJamesImpl extends James {

    private List sNames = null;

    public boolean isLocalServer(String serverName) {

        // Check for wildCard domain

        for (int i = 0; i < sNames.size(); i++) {

            if (((String) sNames.get(i)).endsWith(serverName.toLowerCase())) {

                return true;

            }

        }

        // Call overriden method

        return super.isLocalServer(serverName);

    }

    public void configure(Configuration conf) {

        // Get the domains and hosts served by this instance

        sNames = new ArrayList();

        final Configuration[] serverNameConfs = 
conf.getChild("wildcardservernames")

                .getChildren("servername");

        for (int i = 0; i < serverNameConfs.length; i++) {

            try {

                sNames.add(serverNameConfs[i].getValue().toLowerCase(

                        Locale.US));

            } catch (ConfigurationException e) {

                throw new RuntimeException(e);

            }

        }

        super.configure(conf);

    }

}

----------------------------------------------


2. Copy the James.xinfo to MyJamesImpl.xinfo

3. Create a new Matcher which match wildcard entries:
------------------------------------------------------------------

package org.apache.james.transport.matchers;

import java.util.ArrayList;

import java.util.List;

import java.util.Locale;

import java.util.StringTokenizer;

import org.apache.mailet.GenericRecipientMatcher;

import org.apache.mailet.MailAddress;

public class WildCardHostIs extends GenericRecipientMatcher {

    private List hosts;

    public void init() {

        StringTokenizer st = new StringTokenizer(getCondition(), ", ", false);

        hosts = new ArrayList();

        while (st.hasMoreTokens()) {

            hosts.add(st.nextToken().toLowerCase(Locale.US));

        }

    }

    public boolean matchRecipient(MailAddress recipient) {

        for (int i = 0; i < hosts.size(); i++) {

            if (((String) 
hosts.get(i)).endsWith(recipient.getHost().toLowerCase(Locale.US))) {

                return true;

            }

        }

        return false;

    }

}

---------------------------------------------------------------------------

4.change assembly.xml to use your MyJamesImpl:

----------------------------------------------------------

<block name="James" class="org.apache.james.MyJamesImpl">

------------------------------------------------------------

5. Add the new configuration stuff to config.xml:

------------------------------------------------------------


- <#> <wildcardservernames>
      <servername>.apache.org</servername>
</wildcardservernames>

--------------------------------------------------------------


6. Use your new Matcher with RemoteDelivery.
7. Start James and be happy ;-)


bye
Norman

Ps: The code is untested, but I hope you now understand what you need...


Gary Jarrel schrieb:
> Thank you for that Norman.
>
> The solution works, the only problem, it needs to work for any given
> domain on the net. Meaning xyz.com can be anything! As long as
> tracker.com is appended to the end of the email address, the server
> needs to be able to receive it, process it, and forward it on.
>
> Thank you!
>
> Gary
>
> On 4/21/07, Norman Maurer <[EMAIL PROTECTED]> wrote:
>> Hi Gary,
>>
>> im not sure i understand you correctly but here is what I whould do:
>>
>>    1. Add xyz.com.track.com to servernames section of config.xml
>>    2. Add an Mailet which extend AddFooter Mailet to provide methods to
>>       add a gif to the email and put it in the Mailet chain
>>    3. Add a RemoteDelivery Mailet which use a gateway configured which
>>       points to your final Mail Server.
>>
>>
>> Here is an simple Example of what I whould do:
>>
>> .....
>>
>> <servernames autodetect="false" autodetectIP="true">
>>          <servername>xyz.com.track.com </servername>
>> </servernames>
>> ....
>>
>>
>> <processor name="root">
>> ......
>>
>>     <mailet match="All" class="YourAddFooterImpl"/>
>> ......
>>
>>     <mailet match="HostIs=xyz.com.track.com" RemoteDelivery">
>>         .....
>>         <gateway> your.final.mail.destination </gateway>
>>         <gatewayPort>25</gatewayPort>
>>     </mailet>
>>
>> ....
>>
>>
>> I hope this was helpfull.
>>
>> bye
>> Norman
>>
>>
>> Gary Jarrel schrieb:
>> > Hi All!
>> >
>> > Sorry for all the questions, but I'm playing around with using James
>> > as a tracker server similar to the way that read notify and others
>> > work!
>> >
>> > Eg. If I have a domain say track.com and someone sends an email to
>> > [EMAIL PROTECTED] it relays through the track.com mail server
>> > where I suppose AddFooter mailet can be used to append a GIF image to
>> > the email, and forward that onto [EMAIL PROTECTED]
>> >
>> > I suppose that this maybe a bit off topic for a James user list, but
>> > how would I get this email to relay through track.com and James to
>> > accept it and forward it on?
>> >
>> > Thank you!
>> >
>> > Gary
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> > !EXCUBATOR:1,4629915e39891906917090!
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> !DSPAM:1,4629c78d324329713411250!
>
>


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

Reply via email to