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 Cole Ferrier <co...@coleferrier.com> on 2012/05/08 18:42:37 UTC

MX record peference not being honored?

We have an internal mail system that has 6 MX records 3 at priority 10 (new
servers recently added) and 3 at priority 20 (old servers that where
previously at 10).

and it appears that apache james 2.3 is sending mail to all of them about
equally?

i was instructed that it should only connect to the 20's when all of the
10s are unavailable?

any help would be appreciated?

(or is there any need to restart James? aka, how long does it cache its
data about the MX preferences?)

Cole

Re: MX record peference not being honored?

Posted by Ioan Eugen Stan <st...@gmail.com>.
Hi again,

I took a look at the code in James 3 to see if there are ig changes
and I have found https://issues.apache.org/jira/browse/JAMES-913 .
Take a look and see if this will help you.

Bye,

2012/5/10 Eric Charles <er...@apache.org>:
> Quick note; the behavior in 3.0 should be the same than in 2.3 (except if it
> has been updated since then, didn't take time to check this.).
>
> @Coley
> From the code Ioan pointed, it seems that the priority should be managed,
> and for a same priority, we should have randomization. If this is not the
> expected or effective behavior, please open a JIRA. The fix would be for
> 3.0, but you could easily fix the 2.3 without having to recompile everything
> (simply declaring your own class).
>
> Thx, Eric
>
>
>
> On 05/10/2012 10:32 AM, Ioan Eugen Stan wrote:
>>
>> Hi again,
>>
>>
>> First have a look at RemoteDelivery mailet that sends the email (check
>> the deliver method). It calls getGatewaySMTPHostAddresses which calls
>> the stuff from DNSServer.java.
>>
>>
>> http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
>>
>> If you read the javadoc you should notice some randomization in the MX
>> records.
>>
>> 2012/5/10 Ioan Eugen Stan<st...@gmail.com>:
>>>
>>> Hi Cole,
>>>
>>> I have no experience with 2.3 branch but the code responsible for
>>> routing is loacated in:
>>>
>>> http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/dnsserver/DNSServer.java
>>> . Namely: getSMTPHostAddresses, findMXRecords and findMXRecordsRaw.
>>> The javadoc for findMXRecords shows:
>>>
>>> Sorting is done in findMXRecordsRaw:
>>>
>>>    public List findMXRecordsRaw(String hostname) {
>>>        Record answers[] = lookup(hostname, Type.MX);
>>>        List servers = new ArrayList();
>>>        if (answers == null) {
>>>            return servers;
>>>        }
>>>
>>>        MXRecord mxAnswers[] = new MXRecord[answers.length];
>>>        for (int i = 0; i<  answers.length; i++) {
>>>            mxAnswers[i] = (MXRecord)answers[i];
>>>        }
>>>
>>>        Arrays.sort(mxAnswers, mxComparator);
>>>
>>>        for (int i = 0; i<  mxAnswers.length; i++) {
>>>            servers.add(mxAnswers[i].getTarget ().toString ());
>>>            getLogger().debug(new StringBuffer("Found MX record
>>> ").append(mxAnswers[i].getTarget ().toString ()).toString());
>>>        }
>>>        return servers;
>>>    }
>>>
>>>
>>> MX sorting and randomization is done via:
>>>
>>>    /* RFC 2821 section 5 requires that we sort the MX records by their
>>>     * preference, and introduce a randomization.  This Comparator does
>>>     * comparisons as normal unless the values are equal, in which case
>>>     * it "tosses a coin", randomly speaking.
>>>     *
>>>     * This way MX record w/preference 0 appears before MX record
>>>     * w/preference 1, but a bunch of MX records with the same preference
>>>     * would appear in different orders each time.
>>>     *
>>>     * Reminder for maintainers: the return value on a Comparator can
>>>     * be counter-intuitive for those who aren't used to the old C
>>>     * strcmp function:
>>>     *
>>>     *<  0 ==>  a<  b
>>>     * = 0 ==>  a = b
>>>     *>  0 ==>  a>  b
>>>     */
>>>    private static class MXRecordComparator implements Comparator {
>>>        private final static Random random = new Random();
>>>        public int compare (Object a, Object b) {
>>>            int pa = ((MXRecord)a).getPriority();
>>>            int pb = ((MXRecord)b).getPriority();
>>>            return (pa == pb) ? (512 - random.nextInt(1024)) : pa - pb;
>>>        }
>>>    }
>>>
>>>
>>> Most likely the problems come from here. Hope this helps,
>>>
>>> Cheers,
>>>
>>> 2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>>>
>>>> Recycle of James did not work, it is still equally using all 6 of the
>>>> mail
>>>> servers, even though they are at a different preference levels.
>>>>
>>>> Any Ideas?
>>>>
>>>> Cole
>>>>
>>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>
>>>>  wrote:
>>>>
>>>>> talking with our internal mail system people, all 6 servers had a
>>>>> priority
>>>>> of 10 the last time apache James was restarted.
>>>>>
>>>>> Does James cache this data for the life of it running? or is there a
>>>>> time
>>>>> to live? or?
>>>>>
>>>>> I will schedule a recycle of james to see if it stops using the servers
>>>>> that now have a lower preference.
>>>>>
>>>>> Let me know if you have any ideas in the mean time.
>>>>>
>>>>> Cole
>>>>>
>>>>>
>>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>
>>>>>  wrote:
>>>>>
>>>>>> We have an internal mail system that has 6 MX records 3 at priority 10
>>>>>> (new servers recently added) and 3 at priority 20 (old servers that
>>>>>> where
>>>>>> previously at 10).
>>>>>>
>>>>>> and it appears that apache james 2.3 is sending mail to all of them
>>>>>> about
>>>>>> equally?
>>>>>>
>>>>>> i was instructed that it should only connect to the 20's when all of
>>>>>> the
>>>>>> 10s are unavailable?
>>>>>>
>>>>>> any help would be appreciated?
>>>>>>
>>>>>> (or is there any need to restart James? aka, how long does it cache
>>>>>> its
>>>>>> data about the MX preferences?)
>>>>>>
>>>>>> Cole
>>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>> --
>>> Ioan Eugen Stan
>>> http://ieugen.blogspot.com/  *** http://bucharest-jug.github.com/ ***
>>
>>
>>
>>
>
> --
> eric | http://about.echarles.net | @echarles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>



-- 
Ioan Eugen Stan
http://ieugen.blogspot.com/  *** http://bucharest-jug.github.com/ ***

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


Re: MX record peference not being honored?

Posted by Eric Charles <er...@apache.org>.
Quick note; the behavior in 3.0 should be the same than in 2.3 (except 
if it has been updated since then, didn't take time to check this.).

@Coley
 From the code Ioan pointed, it seems that the priority should be 
managed, and for a same priority, we should have randomization. If this 
is not the expected or effective behavior, please open a JIRA. The fix 
would be for 3.0, but you could easily fix the 2.3 without having to 
recompile everything (simply declaring your own class).

Thx, Eric


On 05/10/2012 10:32 AM, Ioan Eugen Stan wrote:
> Hi again,
>
>
> First have a look at RemoteDelivery mailet that sends the email (check
> the deliver method). It calls getGatewaySMTPHostAddresses which calls
> the stuff from DNSServer.java.
>
> http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java
>
> If you read the javadoc you should notice some randomization in the MX
> records.
>
> 2012/5/10 Ioan Eugen Stan<st...@gmail.com>:
>> Hi Cole,
>>
>> I have no experience with 2.3 branch but the code responsible for
>> routing is loacated in:
>> http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/dnsserver/DNSServer.java
>> . Namely: getSMTPHostAddresses, findMXRecords and findMXRecordsRaw.
>> The javadoc for findMXRecords shows:
>>
>> Sorting is done in findMXRecordsRaw:
>>
>>     public List findMXRecordsRaw(String hostname) {
>>         Record answers[] = lookup(hostname, Type.MX);
>>         List servers = new ArrayList();
>>         if (answers == null) {
>>             return servers;
>>         }
>>
>>         MXRecord mxAnswers[] = new MXRecord[answers.length];
>>         for (int i = 0; i<  answers.length; i++) {
>>             mxAnswers[i] = (MXRecord)answers[i];
>>         }
>>
>>         Arrays.sort(mxAnswers, mxComparator);
>>
>>         for (int i = 0; i<  mxAnswers.length; i++) {
>>             servers.add(mxAnswers[i].getTarget ().toString ());
>>             getLogger().debug(new StringBuffer("Found MX record
>> ").append(mxAnswers[i].getTarget ().toString ()).toString());
>>         }
>>         return servers;
>>     }
>>
>>
>> MX sorting and randomization is done via:
>>
>>     /* RFC 2821 section 5 requires that we sort the MX records by their
>>      * preference, and introduce a randomization.  This Comparator does
>>      * comparisons as normal unless the values are equal, in which case
>>      * it "tosses a coin", randomly speaking.
>>      *
>>      * This way MX record w/preference 0 appears before MX record
>>      * w/preference 1, but a bunch of MX records with the same preference
>>      * would appear in different orders each time.
>>      *
>>      * Reminder for maintainers: the return value on a Comparator can
>>      * be counter-intuitive for those who aren't used to the old C
>>      * strcmp function:
>>      *
>>      *<  0 ==>  a<  b
>>      * = 0 ==>  a = b
>>      *>  0 ==>  a>  b
>>      */
>>     private static class MXRecordComparator implements Comparator {
>>         private final static Random random = new Random();
>>         public int compare (Object a, Object b) {
>>             int pa = ((MXRecord)a).getPriority();
>>             int pb = ((MXRecord)b).getPriority();
>>             return (pa == pb) ? (512 - random.nextInt(1024)) : pa - pb;
>>         }
>>     }
>>
>>
>> Most likely the problems come from here. Hope this helps,
>>
>> Cheers,
>>
>> 2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>> Recycle of James did not work, it is still equally using all 6 of the mail
>>> servers, even though they are at a different preference levels.
>>>
>>> Any Ideas?
>>>
>>> Cole
>>>
>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>  wrote:
>>>
>>>> talking with our internal mail system people, all 6 servers had a priority
>>>> of 10 the last time apache James was restarted.
>>>>
>>>> Does James cache this data for the life of it running? or is there a time
>>>> to live? or?
>>>>
>>>> I will schedule a recycle of james to see if it stops using the servers
>>>> that now have a lower preference.
>>>>
>>>> Let me know if you have any ideas in the mean time.
>>>>
>>>> Cole
>>>>
>>>>
>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>  wrote:
>>>>
>>>>> We have an internal mail system that has 6 MX records 3 at priority 10
>>>>> (new servers recently added) and 3 at priority 20 (old servers that where
>>>>> previously at 10).
>>>>>
>>>>> and it appears that apache james 2.3 is sending mail to all of them about
>>>>> equally?
>>>>>
>>>>> i was instructed that it should only connect to the 20's when all of the
>>>>> 10s are unavailable?
>>>>>
>>>>> any help would be appreciated?
>>>>>
>>>>> (or is there any need to restart James? aka, how long does it cache its
>>>>> data about the MX preferences?)
>>>>>
>>>>> Cole
>>>>>
>>>>
>>>>
>>
>>
>>
>> --
>> Ioan Eugen Stan
>> http://ieugen.blogspot.com/  *** http://bucharest-jug.github.com/ ***
>
>
>

-- 
eric | http://about.echarles.net | @echarles

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


Re: MX record peference not being honored?

Posted by Ioan Eugen Stan <st...@gmail.com>.
Hi again,


First have a look at RemoteDelivery mailet that sends the email (check
the deliver method). It calls getGatewaySMTPHostAddresses which calls
the stuff from DNSServer.java.

http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/transport/mailets/RemoteDelivery.java

If you read the javadoc you should notice some randomization in the MX
records.

2012/5/10 Ioan Eugen Stan <st...@gmail.com>:
> Hi Cole,
>
> I have no experience with 2.3 branch but the code responsible for
> routing is loacated in:
> http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/dnsserver/DNSServer.java
> . Namely: getSMTPHostAddresses, findMXRecords and findMXRecordsRaw.
> The javadoc for findMXRecords shows:
>
> Sorting is done in findMXRecordsRaw:
>
>    public List findMXRecordsRaw(String hostname) {
>        Record answers[] = lookup(hostname, Type.MX);
>        List servers = new ArrayList();
>        if (answers == null) {
>            return servers;
>        }
>
>        MXRecord mxAnswers[] = new MXRecord[answers.length];
>        for (int i = 0; i < answers.length; i++) {
>            mxAnswers[i] = (MXRecord)answers[i];
>        }
>
>        Arrays.sort(mxAnswers, mxComparator);
>
>        for (int i = 0; i < mxAnswers.length; i++) {
>            servers.add(mxAnswers[i].getTarget ().toString ());
>            getLogger().debug(new StringBuffer("Found MX record
> ").append(mxAnswers[i].getTarget ().toString ()).toString());
>        }
>        return servers;
>    }
>
>
> MX sorting and randomization is done via:
>
>    /* RFC 2821 section 5 requires that we sort the MX records by their
>     * preference, and introduce a randomization.  This Comparator does
>     * comparisons as normal unless the values are equal, in which case
>     * it "tosses a coin", randomly speaking.
>     *
>     * This way MX record w/preference 0 appears before MX record
>     * w/preference 1, but a bunch of MX records with the same preference
>     * would appear in different orders each time.
>     *
>     * Reminder for maintainers: the return value on a Comparator can
>     * be counter-intuitive for those who aren't used to the old C
>     * strcmp function:
>     *
>     * < 0 ==> a < b
>     * = 0 ==> a = b
>     * > 0 ==> a > b
>     */
>    private static class MXRecordComparator implements Comparator {
>        private final static Random random = new Random();
>        public int compare (Object a, Object b) {
>            int pa = ((MXRecord)a).getPriority();
>            int pb = ((MXRecord)b).getPriority();
>            return (pa == pb) ? (512 - random.nextInt(1024)) : pa - pb;
>        }
>    }
>
>
> Most likely the problems come from here. Hope this helps,
>
> Cheers,
>
> 2012/5/9 Cole Ferrier <co...@coleferrier.com>:
>> Recycle of James did not work, it is still equally using all 6 of the mail
>> servers, even though they are at a different preference levels.
>>
>> Any Ideas?
>>
>> Cole
>>
>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier <co...@coleferrier.com> wrote:
>>
>>> talking with our internal mail system people, all 6 servers had a priority
>>> of 10 the last time apache James was restarted.
>>>
>>> Does James cache this data for the life of it running? or is there a time
>>> to live? or?
>>>
>>> I will schedule a recycle of james to see if it stops using the servers
>>> that now have a lower preference.
>>>
>>> Let me know if you have any ideas in the mean time.
>>>
>>> Cole
>>>
>>>
>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier <co...@coleferrier.com> wrote:
>>>
>>>> We have an internal mail system that has 6 MX records 3 at priority 10
>>>> (new servers recently added) and 3 at priority 20 (old servers that where
>>>> previously at 10).
>>>>
>>>> and it appears that apache james 2.3 is sending mail to all of them about
>>>> equally?
>>>>
>>>> i was instructed that it should only connect to the 20's when all of the
>>>> 10s are unavailable?
>>>>
>>>> any help would be appreciated?
>>>>
>>>> (or is there any need to restart James? aka, how long does it cache its
>>>> data about the MX preferences?)
>>>>
>>>> Cole
>>>>
>>>
>>>
>
>
>
> --
> Ioan Eugen Stan
> http://ieugen.blogspot.com/  *** http://bucharest-jug.github.com/ ***



-- 
Ioan Eugen Stan
http://ieugen.blogspot.com/  *** http://bucharest-jug.github.com/ ***

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


Re: MX record peference not being honored?

Posted by Ioan Eugen Stan <st...@gmail.com>.
Hi Cole,

I have no experience with 2.3 branch but the code responsible for
routing is loacated in:
http://svn.apache.org/repos/asf/james/server/branches/v2.3/src/java/org/apache/james/dnsserver/DNSServer.java
. Namely: getSMTPHostAddresses, findMXRecords and findMXRecordsRaw.
The javadoc for findMXRecords shows:

Sorting is done in findMXRecordsRaw:

    public List findMXRecordsRaw(String hostname) {
        Record answers[] = lookup(hostname, Type.MX);
        List servers = new ArrayList();
        if (answers == null) {
            return servers;
        }

        MXRecord mxAnswers[] = new MXRecord[answers.length];
        for (int i = 0; i < answers.length; i++) {
            mxAnswers[i] = (MXRecord)answers[i];
        }

        Arrays.sort(mxAnswers, mxComparator);

        for (int i = 0; i < mxAnswers.length; i++) {
            servers.add(mxAnswers[i].getTarget ().toString ());
            getLogger().debug(new StringBuffer("Found MX record
").append(mxAnswers[i].getTarget ().toString ()).toString());
        }
        return servers;
    }


MX sorting and randomization is done via:

    /* RFC 2821 section 5 requires that we sort the MX records by their
     * preference, and introduce a randomization.  This Comparator does
     * comparisons as normal unless the values are equal, in which case
     * it "tosses a coin", randomly speaking.
     *
     * This way MX record w/preference 0 appears before MX record
     * w/preference 1, but a bunch of MX records with the same preference
     * would appear in different orders each time.
     *
     * Reminder for maintainers: the return value on a Comparator can
     * be counter-intuitive for those who aren't used to the old C
     * strcmp function:
     *
     * < 0 ==> a < b
     * = 0 ==> a = b
     * > 0 ==> a > b
     */
    private static class MXRecordComparator implements Comparator {
        private final static Random random = new Random();
        public int compare (Object a, Object b) {
            int pa = ((MXRecord)a).getPriority();
            int pb = ((MXRecord)b).getPriority();
            return (pa == pb) ? (512 - random.nextInt(1024)) : pa - pb;
        }
    }


Most likely the problems come from here. Hope this helps,

Cheers,

2012/5/9 Cole Ferrier <co...@coleferrier.com>:
> Recycle of James did not work, it is still equally using all 6 of the mail
> servers, even though they are at a different preference levels.
>
> Any Ideas?
>
> Cole
>
> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier <co...@coleferrier.com> wrote:
>
>> talking with our internal mail system people, all 6 servers had a priority
>> of 10 the last time apache James was restarted.
>>
>> Does James cache this data for the life of it running? or is there a time
>> to live? or?
>>
>> I will schedule a recycle of james to see if it stops using the servers
>> that now have a lower preference.
>>
>> Let me know if you have any ideas in the mean time.
>>
>> Cole
>>
>>
>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier <co...@coleferrier.com> wrote:
>>
>>> We have an internal mail system that has 6 MX records 3 at priority 10
>>> (new servers recently added) and 3 at priority 20 (old servers that where
>>> previously at 10).
>>>
>>> and it appears that apache james 2.3 is sending mail to all of them about
>>> equally?
>>>
>>> i was instructed that it should only connect to the 20's when all of the
>>> 10s are unavailable?
>>>
>>> any help would be appreciated?
>>>
>>> (or is there any need to restart James? aka, how long does it cache its
>>> data about the MX preferences?)
>>>
>>> Cole
>>>
>>
>>



-- 
Ioan Eugen Stan
http://ieugen.blogspot.com/  *** http://bucharest-jug.github.com/ ***

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


Re: MX record peference not being honored?

Posted by Stefano Bagnara <ap...@bago.org>.
2012/5/14 Cole Ferrier <co...@coleferrier.com>:
> See attached. I sorta hacked it into it, and allowed a new config option to
> use MXlookups for the first SMTP server address.
>
> Thoughts?

Attachments are stripped by the mailing list. Please open a JIRA issue.

Stefano

> On Mon, May 14, 2012 at 1:40 AM, Eric Charles <er...@apache.org> wrote:
>>
>> Hi,
>>
>> To achieve this, you will need to develop your own custom MailetDelivery
>> mailet based on [1].
>>
>> The current implementation allows you to define multiple gateways.
>> Quoted from javadoc: " a String containing a comma separated list of
>> patterns defining the gateway servers to be used to - deliver mail
>> regardless of the recipient address. If multiple gateway servers are
>> defined, each will be tried in definition order - until delivery is
>> successful. If none are successful, the mail is bounced"
>>
>> This doesn't map your requirement, but you could implement your own logic
>> to balance the traffic between your internal MTAs.
>>
>> Hopes this helps,
>>
>> Eric
>>
>>
>> [1]
>> https://svn.apache.org/repos/asf/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
>>
>>
>> On 05/11/2012 02:53 PM, Cole Ferrier wrote:
>>>
>>> Think about this usecase:
>>>
>>> Internally, we have many servers responsible for relaying mail. (multiple
>>> data centers). Also, they have the concept of servers that are lower
>>> priority, in case all the primary ones have a failure.
>>>
>>> Also, we can not directly send mail outside the firewall, so all mail
>>> must
>>> go through this infrastructure to be sent. (So we must have
>>> smarthost/gateway turned on)
>>>
>>> They can setup/change the list of MX records for the network name we are
>>> supposed to transport mail through whenever they want.
>>>
>>> Thoughts?
>>>
>>> Thanks,
>>>
>>> Cole
>>>
>>> On Fri, May 11, 2012 at 1:24 AM, Eric Charles<er...@apache.org>  wrote:
>>>
>>>> If you specify explicitly a mail gateway, MX record usage does not make
>>>> any sense.
>>>>
>>>> You must see the mail gateway you define as 'hard-coding' the MTA you
>>>> want
>>>> to use, that skips any usage of dynamically defined MX record.
>>>>
>>>> Thx, Eric
>>>>
>>>>
>>>> On 05/10/2012 06:28 PM, Cole Ferrier wrote:
>>>>
>>>>> Ahh, i think i've figured out the problem..
>>>>>
>>>>> We have a requirement to smarthost (transfer all mail through an
>>>>> internal
>>>>> mail relay). so we have set the Mail Gateway up in our remotedelivery
>>>>> mailet.
>>>>>
>>>>>
>>>>> org.apache.james.transport.**mailets.RemoteDeliverydeliver.**deliver(Mail
>>>>>
>>>>> mail,
>>>>> Session session)
>>>>>
>>>>> then in the mailet:
>>>>>
>>>>>             if (gatewayServer == null) {
>>>>>                 MailAddress rcpt = (MailAddress)
>>>>> recipients.iterator().next();
>>>>>                 String host = rcpt.getHost();
>>>>>
>>>>>                 //Lookup the possible targets
>>>>>                 targetServers =
>>>>> getMailetContext().**getSMTPHostAddresses(host);
>>>>>
>>>>>                 if (!targetServers.hasNext()) {
>>>>>                     log("No mail server found for: " + host);
>>>>>                     StringBuffer exceptionBuffer =
>>>>>                         new StringBuffer(128)
>>>>>                         .append("There are no DNS entries for the
>>>>> hostname
>>>>> ")
>>>>>                         .append(host)
>>>>>                         .append(".  I cannot determine where to send
>>>>> this
>>>>> message.");
>>>>>                     return failMessage(mail, new
>>>>> MessagingException(**exceptionBuffer.toString()), false);
>>>>>                 }
>>>>>             } else {
>>>>>                 targetServers = getGatewaySMTPHostAddresses(**
>>>>>
>>>>> gatewayServer);
>>>>>             }
>>>>>
>>>>> we have a gateway server so it goes into the else clause of this block,
>>>>> because it doesn't have to find the mail servers responsible for the
>>>>> domains of the recipients, and it just calls
>>>>> getGatewaySMTPHostAddresses(**gatewayServer);
>>>>>
>>>>>
>>>>> which returns an iterator that just loops through
>>>>>
>>>>> final InetAddress[] ips =
>>>>> org.apache.james.dnsserver.**DNSServer.getAllByName(**nextGateway);
>>>>>
>>>>>
>>>>> which are just all the DNS entries (not MX records) for the gateway
>>>>> server.
>>>>>
>>>>> This is why when i turned up logging to DEBUG on the DNSServer
>>>>> component,
>>>>> i
>>>>> didn't get any meaningful data.
>>>>>
>>>>> So it looks like i have a requirement that i still want MX records to
>>>>> be
>>>>> evaluated while using a mail gateway. Does that make sense?
>>>>>
>>>>> Could i just change this block of code to always call the
>>>>>
>>>>> //Lookup the possible targets
>>>>>                 targetServers =
>>>>> getMailetContext().**getSMTPHostAddresses(host);
>>>>>
>>>>>
>>>>> method?
>>>>>
>>>>> Or?
>>>>>
>>>>> Thoughts?
>>>>>
>>>>> Cole
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 10, 2012 at 3:40 AM, Eric Charles<er...@apache.org>   wrote:
>>>>>
>>>>>  Quick addon if finally the issue is in james code, and further to
>>>>> Ioan's
>>>>>>
>>>>>> point on JIRA, the patch to backport on 2.3 could be
>>>>>>
>>>>>>
>>>>>> http://svn.apache.org/viewvc/****james/server/trunk/**dnsservice-**<http://svn.apache.org/viewvc/**james/server/trunk/dnsservice-**>
>>>>>> dnsjava/src/main/java/org/****apache/james/dnsservice/**
>>>>>> dnsjava/DNSJavaService.java?****r1=1035437&r2=1035436&pathrev=**
>>>>>> **1035437<http://svn.apache.**org/viewvc/james/server/trunk/**
>>>>>> dnsservice-dnsjava/src/main/**java/org/apache/james/**
>>>>>> dnsservice/dnsjava/**DNSJavaService.java?r1=**
>>>>>>
>>>>>>
>>>>>> 1035437&r2=1035436&pathrev=**1035437<http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?r1=1035437&r2=1035436&pathrev=1035437>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> Thx, Eric
>>>>>>
>>>>>>
>>>>>> On 05/10/2012 11:30 AM, Stefano Bagnara wrote:
>>>>>>
>>>>>>  2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>>>>>>
>>>>>>>
>>>>>>>  Recycle of James did not work, it is still equally using all 6 of
>>>>>>> the
>>>>>>>>
>>>>>>>> mail
>>>>>>>> servers, even though they are at a different preference levels.
>>>>>>>>
>>>>>>>> Any Ideas?
>>>>>>>>
>>>>>>>>
>>>>>>> I think you have issues at DNS level.
>>>>>>>
>>>>>>> AFAIK james 2.3 had some bug in MX ordering but I remember only two
>>>>>>> of
>>>>>>> them, and they do not break priority the way you see.
>>>>>>> 1) If james is a relay server for a domain it doesn't take care to
>>>>>>> only relay to "lower priority" servers resulting into loops if the
>>>>>>> high priority servers are not available (this is not your case).
>>>>>>> 2) James does sort MX hosts, but uses a comparator that is not
>>>>>>> "consistent with equals"
>>>>>>>
>>>>>>> (http://docs.oracle.com/****javase/1.4.2/docs/api/java/**<http://docs.oracle.com/**javase/1.4.2/docs/api/java/**>
>>>>>>> util/Comparator.html<http://**docs.oracle.com/javase/1.4.2/**
>>>>>>>
>>>>>>> docs/api/java/util/Comparator.**html<http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html>
>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> ).
>>>>>>> This is not necessarily a bad thing as it will correctly sort results
>>>>>>> using the priority but often will return servers with the same
>>>>>>> priority "not shuffled": more often than not, MX are already shuffled
>>>>>>> on the DNS side so this doesn't have a big impact (and is not your
>>>>>>> case).
>>>>>>>
>>>>>>> So check what DNS servers your james is using and make sure that very
>>>>>>> specific DNS servers have updated informations.
>>>>>>>
>>>>>>> Stefano
>>>>>>>
>>>>>>>  Cole
>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>
>>>>>>>>  wrote:
>>>>>>>>
>>>>>>>>  talking with our internal mail system people, all 6 servers had a
>>>>>>>>
>>>>>>>>> priority
>>>>>>>>> of 10 the last time apache James was restarted.
>>>>>>>>>
>>>>>>>>> Does James cache this data for the life of it running? or is there
>>>>>>>>> a
>>>>>>>>> time
>>>>>>>>> to live? or?
>>>>>>>>>
>>>>>>>>> I will schedule a recycle of james to see if it stops using the
>>>>>>>>> servers
>>>>>>>>> that now have a lower preference.
>>>>>>>>>
>>>>>>>>> Let me know if you have any ideas in the mean time.
>>>>>>>>>
>>>>>>>>> Cole
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>
>>>>>>>>>  wrote:
>>>>>>>>>
>>>>>>>>>  We have an internal mail system that has 6 MX records 3 at
>>>>>>>>> priority
>>>>>>>>> 10
>>>>>>>>>
>>>>>>>>>> (new servers recently added) and 3 at priority 20 (old servers
>>>>>>>>>> that
>>>>>>>>>> where
>>>>>>>>>> previously at 10).
>>>>>>>>>>
>>>>>>>>>> and it appears that apache james 2.3 is sending mail to all of
>>>>>>>>>> them
>>>>>>>>>> about
>>>>>>>>>> equally?
>>>>>>>>>>
>>>>>>>>>> i was instructed that it should only connect to the 20's when all
>>>>>>>>>> of
>>>>>>>>>> the
>>>>>>>>>> 10s are unavailable?
>>>>>>>>>>
>>>>>>>>>> any help would be appreciated?
>>>>>>>>>>
>>>>>>>>>> (or is there any need to restart James? aka, how long does it
>>>>>>>>>> cache
>>>>>>>>>> its
>>>>>>>>>> data about the MX preferences?)
>>>>>>>>>>
>>>>>>>>>> Cole
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  ------------------------------****----------------------------**
>>>>>>>
>>>>>>> --**---------
>>>>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.****apache.org<
>>>>>>>
>>>>>>> server-user-**unsubscribe@james.apache.org<se...@james.apache.org>
>>>>>>>>
>>>>>>>>
>>>>>>> For additional commands, e-mail:
>>>>>>> server-user-help@james.apache.****org<
>>>>>>>
>>>>>>> server-user-help@james.**apache.org<se...@james.apache.org>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>  --
>>>>>>
>>>>>> eric | http://about.echarles.net | @echarles
>>>>>>
>>>>>> ------------------------------****----------------------------**
>>>>>> --**---------
>>>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.****apache.org<
>>>>>>
>>>>>> server-user-**unsubscribe@james.apache.org<se...@james.apache.org>
>>>>>>>
>>>>>>>
>>>>>> For additional commands, e-mail:
>>>>>> server-user-help@james.apache.****org<
>>>>>>
>>>>>> server-user-help@james.**apache.org<se...@james.apache.org>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>> --
>>>> eric | http://about.echarles.net | @echarles
>>>>
>>>>
>>>> ------------------------------**------------------------------**---------
>>>> To unsubscribe, e-mail:
>>>> server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
>>>> For additional commands, e-mail:
>>>> server-user-help@james.apache.**org<se...@james.apache.org>
>>>>
>>>>
>>>
>>
>> --
>> eric | http://about.echarles.net | @echarles
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-user-help@james.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org

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


Re: MX record peference not being honored?

Posted by Cole Ferrier <co...@coleferrier.com>.
See attached. I sorta hacked it into it, and allowed a new config option to
use MXlookups for the first SMTP server address.

Thoughts?



On Mon, May 14, 2012 at 1:40 AM, Eric Charles <er...@apache.org> wrote:

> Hi,
>
> To achieve this, you will need to develop your own custom MailetDelivery
> mailet based on [1].
>
> The current implementation allows you to define multiple gateways.
> Quoted from javadoc: " a String containing a comma separated list of
> patterns defining the gateway servers to be used to - deliver mail
> regardless of the recipient address. If multiple gateway servers are
> defined, each will be tried in definition order - until delivery is
> successful. If none are successful, the mail is bounced"
>
> This doesn't map your requirement, but you could implement your own logic
> to balance the traffic between your internal MTAs.
>
> Hopes this helps,
>
> Eric
>
>
> [1] https://svn.apache.org/repos/**asf/james/server/trunk/**
> mailets/src/main/java/org/**apache/james/transport/**
> mailets/RemoteDelivery.java<https://svn.apache.org/repos/asf/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java>
>
>
> On 05/11/2012 02:53 PM, Cole Ferrier wrote:
>
>> Think about this usecase:
>>
>> Internally, we have many servers responsible for relaying mail. (multiple
>> data centers). Also, they have the concept of servers that are lower
>> priority, in case all the primary ones have a failure.
>>
>> Also, we can not directly send mail outside the firewall, so all mail must
>> go through this infrastructure to be sent. (So we must have
>> smarthost/gateway turned on)
>>
>> They can setup/change the list of MX records for the network name we are
>> supposed to transport mail through whenever they want.
>>
>> Thoughts?
>>
>> Thanks,
>>
>> Cole
>>
>> On Fri, May 11, 2012 at 1:24 AM, Eric Charles<er...@apache.org>  wrote:
>>
>>  If you specify explicitly a mail gateway, MX record usage does not make
>>> any sense.
>>>
>>> You must see the mail gateway you define as 'hard-coding' the MTA you
>>> want
>>> to use, that skips any usage of dynamically defined MX record.
>>>
>>> Thx, Eric
>>>
>>>
>>> On 05/10/2012 06:28 PM, Cole Ferrier wrote:
>>>
>>>  Ahh, i think i've figured out the problem..
>>>>
>>>> We have a requirement to smarthost (transfer all mail through an
>>>> internal
>>>> mail relay). so we have set the Mail Gateway up in our remotedelivery
>>>> mailet.
>>>>
>>>> org.apache.james.transport.****mailets.RemoteDeliverydeliver.**
>>>> **deliver(Mail
>>>>
>>>> mail,
>>>> Session session)
>>>>
>>>> then in the mailet:
>>>>
>>>>             if (gatewayServer == null) {
>>>>                 MailAddress rcpt = (MailAddress)
>>>> recipients.iterator().next();
>>>>                 String host = rcpt.getHost();
>>>>
>>>>                 //Lookup the possible targets
>>>>                 targetServers =
>>>> getMailetContext().****getSMTPHostAddresses(host);
>>>>
>>>>                 if (!targetServers.hasNext()) {
>>>>                     log("No mail server found for: " + host);
>>>>                     StringBuffer exceptionBuffer =
>>>>                         new StringBuffer(128)
>>>>                         .append("There are no DNS entries for the
>>>> hostname
>>>> ")
>>>>                         .append(host)
>>>>                         .append(".  I cannot determine where to send
>>>> this
>>>> message.");
>>>>                     return failMessage(mail, new
>>>> MessagingException(****exceptionBuffer.toString()), false);
>>>>                 }
>>>>             } else {
>>>>                 targetServers = getGatewaySMTPHostAddresses(**
>>>>
>>>> gatewayServer);
>>>>             }
>>>>
>>>> we have a gateway server so it goes into the else clause of this block,
>>>> because it doesn't have to find the mail servers responsible for the
>>>> domains of the recipients, and it just calls
>>>> getGatewaySMTPHostAddresses(****gatewayServer);
>>>>
>>>>
>>>> which returns an iterator that just loops through
>>>>
>>>> final InetAddress[] ips =
>>>> org.apache.james.dnsserver.****DNSServer.getAllByName(****nextGateway);
>>>>
>>>>
>>>> which are just all the DNS entries (not MX records) for the gateway
>>>> server.
>>>>
>>>> This is why when i turned up logging to DEBUG on the DNSServer
>>>> component,
>>>> i
>>>> didn't get any meaningful data.
>>>>
>>>> So it looks like i have a requirement that i still want MX records to be
>>>> evaluated while using a mail gateway. Does that make sense?
>>>>
>>>> Could i just change this block of code to always call the
>>>>
>>>> //Lookup the possible targets
>>>>                 targetServers =
>>>> getMailetContext().****getSMTPHostAddresses(host);
>>>>
>>>>
>>>> method?
>>>>
>>>> Or?
>>>>
>>>> Thoughts?
>>>>
>>>> Cole
>>>>
>>>>
>>>>
>>>> On Thu, May 10, 2012 at 3:40 AM, Eric Charles<er...@apache.org>   wrote:
>>>>
>>>>  Quick addon if finally the issue is in james code, and further to
>>>> Ioan's
>>>>
>>>>> point on JIRA, the patch to backport on 2.3 could be
>>>>>
>>>>> http://svn.apache.org/viewvc/******james/server/trunk/****
>>>>> dnsservice-**<http://svn.apache.org/viewvc/****james/server/trunk/**dnsservice-**>
>>>>> <http://svn.**apache.org/viewvc/**james/**server/trunk/dnsservice-**<http://svn.apache.org/viewvc/**james/server/trunk/dnsservice-**>
>>>>> >
>>>>> dnsjava/src/main/java/org/******apache/james/dnsservice/**
>>>>> dnsjava/DNSJavaService.java?******r1=1035437&r2=1035436&**pathrev=**
>>>>> **1035437<http://svn.apache.****org/viewvc/james/server/trunk/****
>>>>> dnsservice-dnsjava/src/main/****java/org/apache/james/**
>>>>> dnsservice/dnsjava/****DNSJavaService.java?r1=**
>>>>>
>>>>> 1035437&r2=1035436&pathrev=****1035437<http://svn.apache.org/**
>>>>> viewvc/james/server/trunk/**dnsservice-dnsjava/src/main/**
>>>>> java/org/apache/james/**dnsservice/dnsjava/**DNSJavaService.java?r1=**
>>>>> 1035437&r2=1035436&pathrev=**1035437<http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?r1=1035437&r2=1035436&pathrev=1035437>
>>>>> >
>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> Thx, Eric
>>>>>
>>>>>
>>>>> On 05/10/2012 11:30 AM, Stefano Bagnara wrote:
>>>>>
>>>>>  2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>>>>
>>>>>>
>>>>>>  Recycle of James did not work, it is still equally using all 6 of the
>>>>>>
>>>>>>> mail
>>>>>>> servers, even though they are at a different preference levels.
>>>>>>>
>>>>>>> Any Ideas?
>>>>>>>
>>>>>>>
>>>>>>>  I think you have issues at DNS level.
>>>>>>
>>>>>> AFAIK james 2.3 had some bug in MX ordering but I remember only two of
>>>>>> them, and they do not break priority the way you see.
>>>>>> 1) If james is a relay server for a domain it doesn't take care to
>>>>>> only relay to "lower priority" servers resulting into loops if the
>>>>>> high priority servers are not available (this is not your case).
>>>>>> 2) James does sort MX hosts, but uses a comparator that is not
>>>>>> "consistent with equals"
>>>>>> (http://docs.oracle.com/******javase/1.4.2/docs/api/java/**<http://docs.oracle.com/****javase/1.4.2/docs/api/java/**>
>>>>>> <**http://docs.oracle.com/****javase/1.4.2/docs/api/java/**<http://docs.oracle.com/**javase/1.4.2/docs/api/java/**>
>>>>>> >
>>>>>> util/Comparator.html<http://****docs.oracle.com/javase/1.4.2/****<http://docs.oracle.com/javase/1.4.2/**>
>>>>>> docs/api/java/util/Comparator.****html<http://docs.oracle.com/**
>>>>>> javase/1.4.2/docs/api/java/**util/Comparator.html<http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html>
>>>>>> >
>>>>>>
>>>>>>
>>>>>>>
>>>>>> ).
>>>>>> This is not necessarily a bad thing as it will correctly sort results
>>>>>> using the priority but often will return servers with the same
>>>>>> priority "not shuffled": more often than not, MX are already shuffled
>>>>>> on the DNS side so this doesn't have a big impact (and is not your
>>>>>> case).
>>>>>>
>>>>>> So check what DNS servers your james is using and make sure that very
>>>>>> specific DNS servers have updated informations.
>>>>>>
>>>>>> Stefano
>>>>>>
>>>>>>  Cole
>>>>>>
>>>>>>
>>>>>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>
>>>>>>>  wrote:
>>>>>>>
>>>>>>>  talking with our internal mail system people, all 6 servers had a
>>>>>>>
>>>>>>>  priority
>>>>>>>> of 10 the last time apache James was restarted.
>>>>>>>>
>>>>>>>> Does James cache this data for the life of it running? or is there a
>>>>>>>> time
>>>>>>>> to live? or?
>>>>>>>>
>>>>>>>> I will schedule a recycle of james to see if it stops using the
>>>>>>>> servers
>>>>>>>> that now have a lower preference.
>>>>>>>>
>>>>>>>> Let me know if you have any ideas in the mean time.
>>>>>>>>
>>>>>>>> Cole
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>
>>>>>>>>  wrote:
>>>>>>>>
>>>>>>>>  We have an internal mail system that has 6 MX records 3 at priority
>>>>>>>> 10
>>>>>>>>
>>>>>>>>  (new servers recently added) and 3 at priority 20 (old servers that
>>>>>>>>> where
>>>>>>>>> previously at 10).
>>>>>>>>>
>>>>>>>>> and it appears that apache james 2.3 is sending mail to all of them
>>>>>>>>> about
>>>>>>>>> equally?
>>>>>>>>>
>>>>>>>>> i was instructed that it should only connect to the 20's when all
>>>>>>>>> of
>>>>>>>>> the
>>>>>>>>> 10s are unavailable?
>>>>>>>>>
>>>>>>>>> any help would be appreciated?
>>>>>>>>>
>>>>>>>>> (or is there any need to restart James? aka, how long does it cache
>>>>>>>>> its
>>>>>>>>> data about the MX preferences?)
>>>>>>>>>
>>>>>>>>> Cole
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>  ------------------------------******--------------------------**
>>>>>>>> --**
>>>>>>>>
>>>>>>> --**---------
>>>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.******
>>>>>> apache.org<
>>>>>> server-user-**unsubscribe@**james.apache.org<un...@james.apache.org>
>>>>>> <se...@james.apache.org>
>>>>>> >
>>>>>>
>>>>>>>
>>>>>>>  For additional commands, e-mail: server-user-help@james.apache.**
>>>>>> ****org<
>>>>>> server-user-help@james.**apach**e.org <http://apache.org><
>>>>>> server-user-help@james.**apache.org<se...@james.apache.org>
>>>>>> >
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>>
>>>>> eric | http://about.echarles.net | @echarles
>>>>>
>>>>> ------------------------------******--------------------------**--**
>>>>> --**---------
>>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.******apache.org
>>>>> <
>>>>> server-user-**unsubscribe@**james.apache.org<un...@james.apache.org>
>>>>> <se...@james.apache.org>
>>>>> >
>>>>>
>>>>>>
>>>>>>  For additional commands, e-mail: server-user-help@james.apache.**
>>>>> ****org<
>>>>> server-user-help@james.**apach**e.org <http://apache.org><
>>>>> server-user-help@james.**apache.org<se...@james.apache.org>
>>>>> >>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>  --
>>> eric | http://about.echarles.net | @echarles
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: server-user-unsubscribe@james.****apache.org<
>>> server-user-**unsubscribe@james.apache.org<se...@james.apache.org>
>>> >
>>> For additional commands, e-mail: server-user-help@james.apache.****org<
>>> server-user-help@james.**apache.org <se...@james.apache.org>>
>>>
>>>
>>>
>>
> --
> eric | http://about.echarles.net | @echarles
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
> For additional commands, e-mail: server-user-help@james.apache.**org<se...@james.apache.org>
>
>

Re: MX record peference not being honored?

Posted by Eric Charles <er...@apache.org>.
Hi,

To achieve this, you will need to develop your own custom MailetDelivery 
mailet based on [1].

The current implementation allows you to define multiple gateways.
Quoted from javadoc: " a String containing a comma separated list of 
patterns defining the gateway servers to be used to - deliver mail 
regardless of the recipient address. If multiple gateway servers are 
defined, each will be tried in definition order - until delivery is 
successful. If none are successful, the mail is bounced"

This doesn't map your requirement, but you could implement your own 
logic to balance the traffic between your internal MTAs.

Hopes this helps,

Eric


[1] 
https://svn.apache.org/repos/asf/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java

On 05/11/2012 02:53 PM, Cole Ferrier wrote:
> Think about this usecase:
>
> Internally, we have many servers responsible for relaying mail. (multiple
> data centers). Also, they have the concept of servers that are lower
> priority, in case all the primary ones have a failure.
>
> Also, we can not directly send mail outside the firewall, so all mail must
> go through this infrastructure to be sent. (So we must have
> smarthost/gateway turned on)
>
> They can setup/change the list of MX records for the network name we are
> supposed to transport mail through whenever they want.
>
> Thoughts?
>
> Thanks,
>
> Cole
>
> On Fri, May 11, 2012 at 1:24 AM, Eric Charles<er...@apache.org>  wrote:
>
>> If you specify explicitly a mail gateway, MX record usage does not make
>> any sense.
>>
>> You must see the mail gateway you define as 'hard-coding' the MTA you want
>> to use, that skips any usage of dynamically defined MX record.
>>
>> Thx, Eric
>>
>>
>> On 05/10/2012 06:28 PM, Cole Ferrier wrote:
>>
>>> Ahh, i think i've figured out the problem..
>>>
>>> We have a requirement to smarthost (transfer all mail through an internal
>>> mail relay). so we have set the Mail Gateway up in our remotedelivery
>>> mailet.
>>>
>>> org.apache.james.transport.**mailets.RemoteDeliverydeliver.**deliver(Mail
>>> mail,
>>> Session session)
>>>
>>> then in the mailet:
>>>
>>>              if (gatewayServer == null) {
>>>                  MailAddress rcpt = (MailAddress)
>>> recipients.iterator().next();
>>>                  String host = rcpt.getHost();
>>>
>>>                  //Lookup the possible targets
>>>                  targetServers =
>>> getMailetContext().**getSMTPHostAddresses(host);
>>>                  if (!targetServers.hasNext()) {
>>>                      log("No mail server found for: " + host);
>>>                      StringBuffer exceptionBuffer =
>>>                          new StringBuffer(128)
>>>                          .append("There are no DNS entries for the hostname
>>> ")
>>>                          .append(host)
>>>                          .append(".  I cannot determine where to send this
>>> message.");
>>>                      return failMessage(mail, new
>>> MessagingException(**exceptionBuffer.toString()), false);
>>>                  }
>>>              } else {
>>>                  targetServers = getGatewaySMTPHostAddresses(**
>>> gatewayServer);
>>>              }
>>>
>>> we have a gateway server so it goes into the else clause of this block,
>>> because it doesn't have to find the mail servers responsible for the
>>> domains of the recipients, and it just calls
>>> getGatewaySMTPHostAddresses(**gatewayServer);
>>>
>>> which returns an iterator that just loops through
>>>
>>> final InetAddress[] ips =
>>> org.apache.james.dnsserver.**DNSServer.getAllByName(**nextGateway);
>>>
>>> which are just all the DNS entries (not MX records) for the gateway
>>> server.
>>>
>>> This is why when i turned up logging to DEBUG on the DNSServer component,
>>> i
>>> didn't get any meaningful data.
>>>
>>> So it looks like i have a requirement that i still want MX records to be
>>> evaluated while using a mail gateway. Does that make sense?
>>>
>>> Could i just change this block of code to always call the
>>>
>>> //Lookup the possible targets
>>>                  targetServers =
>>> getMailetContext().**getSMTPHostAddresses(host);
>>>
>>> method?
>>>
>>> Or?
>>>
>>> Thoughts?
>>>
>>> Cole
>>>
>>>
>>>
>>> On Thu, May 10, 2012 at 3:40 AM, Eric Charles<er...@apache.org>   wrote:
>>>
>>>   Quick addon if finally the issue is in james code, and further to Ioan's
>>>> point on JIRA, the patch to backport on 2.3 could be
>>>>
>>>> http://svn.apache.org/viewvc/****james/server/trunk/**dnsservice-**<http://svn.apache.org/viewvc/**james/server/trunk/dnsservice-**>
>>>> dnsjava/src/main/java/org/****apache/james/dnsservice/**
>>>> dnsjava/DNSJavaService.java?****r1=1035437&r2=1035436&pathrev=**
>>>> **1035437<http://svn.apache.**org/viewvc/james/server/trunk/**
>>>> dnsservice-dnsjava/src/main/**java/org/apache/james/**
>>>> dnsservice/dnsjava/**DNSJavaService.java?r1=**
>>>> 1035437&r2=1035436&pathrev=**1035437<http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?r1=1035437&r2=1035436&pathrev=1035437>
>>>>>
>>>>
>>>>
>>>> Thx, Eric
>>>>
>>>>
>>>> On 05/10/2012 11:30 AM, Stefano Bagnara wrote:
>>>>
>>>>   2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>>>>
>>>>>   Recycle of James did not work, it is still equally using all 6 of the
>>>>>> mail
>>>>>> servers, even though they are at a different preference levels.
>>>>>>
>>>>>> Any Ideas?
>>>>>>
>>>>>>
>>>>> I think you have issues at DNS level.
>>>>>
>>>>> AFAIK james 2.3 had some bug in MX ordering but I remember only two of
>>>>> them, and they do not break priority the way you see.
>>>>> 1) If james is a relay server for a domain it doesn't take care to
>>>>> only relay to "lower priority" servers resulting into loops if the
>>>>> high priority servers are not available (this is not your case).
>>>>> 2) James does sort MX hosts, but uses a comparator that is not
>>>>> "consistent with equals"
>>>>> (http://docs.oracle.com/****javase/1.4.2/docs/api/java/**<http://docs.oracle.com/**javase/1.4.2/docs/api/java/**>
>>>>> util/Comparator.html<http://**docs.oracle.com/javase/1.4.2/**
>>>>> docs/api/java/util/Comparator.**html<http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html>
>>>>>>
>>>>>
>>>>> ).
>>>>> This is not necessarily a bad thing as it will correctly sort results
>>>>> using the priority but often will return servers with the same
>>>>> priority "not shuffled": more often than not, MX are already shuffled
>>>>> on the DNS side so this doesn't have a big impact (and is not your
>>>>> case).
>>>>>
>>>>> So check what DNS servers your james is using and make sure that very
>>>>> specific DNS servers have updated informations.
>>>>>
>>>>> Stefano
>>>>>
>>>>>   Cole
>>>>>
>>>>>>
>>>>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>
>>>>>>   wrote:
>>>>>>
>>>>>>   talking with our internal mail system people, all 6 servers had a
>>>>>>
>>>>>>> priority
>>>>>>> of 10 the last time apache James was restarted.
>>>>>>>
>>>>>>> Does James cache this data for the life of it running? or is there a
>>>>>>> time
>>>>>>> to live? or?
>>>>>>>
>>>>>>> I will schedule a recycle of james to see if it stops using the
>>>>>>> servers
>>>>>>> that now have a lower preference.
>>>>>>>
>>>>>>> Let me know if you have any ideas in the mean time.
>>>>>>>
>>>>>>> Cole
>>>>>>>
>>>>>>>
>>>>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>
>>>>>>>   wrote:
>>>>>>>
>>>>>>>   We have an internal mail system that has 6 MX records 3 at priority
>>>>>>> 10
>>>>>>>
>>>>>>>> (new servers recently added) and 3 at priority 20 (old servers that
>>>>>>>> where
>>>>>>>> previously at 10).
>>>>>>>>
>>>>>>>> and it appears that apache james 2.3 is sending mail to all of them
>>>>>>>> about
>>>>>>>> equally?
>>>>>>>>
>>>>>>>> i was instructed that it should only connect to the 20's when all of
>>>>>>>> the
>>>>>>>> 10s are unavailable?
>>>>>>>>
>>>>>>>> any help would be appreciated?
>>>>>>>>
>>>>>>>> (or is there any need to restart James? aka, how long does it cache
>>>>>>>> its
>>>>>>>> data about the MX preferences?)
>>>>>>>>
>>>>>>>> Cole
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>   ------------------------------****----------------------------**
>>>>> --**---------
>>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.****apache.org<
>>>>> server-user-**unsubscribe@james.apache.org<se...@james.apache.org>
>>>>>>
>>>>> For additional commands, e-mail: server-user-help@james.apache.****org<
>>>>> server-user-help@james.**apache.org<se...@james.apache.org>
>>>>>>
>>>>>
>>>>>
>>>>>   --
>>>> eric | http://about.echarles.net | @echarles
>>>>
>>>> ------------------------------****----------------------------**
>>>> --**---------
>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.****apache.org<
>>>> server-user-**unsubscribe@james.apache.org<se...@james.apache.org>
>>>>>
>>>> For additional commands, e-mail: server-user-help@james.apache.****org<
>>>> server-user-help@james.**apache.org<se...@james.apache.org>>
>>>>
>>>>
>>>>
>>>
>> --
>> eric | http://about.echarles.net | @echarles
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
>> For additional commands, e-mail: server-user-help@james.apache.**org<se...@james.apache.org>
>>
>>
>

-- 
eric | http://about.echarles.net | @echarles

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


Re: MX record peference not being honored?

Posted by Cole Ferrier <co...@coleferrier.com>.
Think about this usecase:

Internally, we have many servers responsible for relaying mail. (multiple
data centers). Also, they have the concept of servers that are lower
priority, in case all the primary ones have a failure.

Also, we can not directly send mail outside the firewall, so all mail must
go through this infrastructure to be sent. (So we must have
smarthost/gateway turned on)

They can setup/change the list of MX records for the network name we are
supposed to transport mail through whenever they want.

Thoughts?

Thanks,

Cole

On Fri, May 11, 2012 at 1:24 AM, Eric Charles <er...@apache.org> wrote:

> If you specify explicitly a mail gateway, MX record usage does not make
> any sense.
>
> You must see the mail gateway you define as 'hard-coding' the MTA you want
> to use, that skips any usage of dynamically defined MX record.
>
> Thx, Eric
>
>
> On 05/10/2012 06:28 PM, Cole Ferrier wrote:
>
>> Ahh, i think i've figured out the problem..
>>
>> We have a requirement to smarthost (transfer all mail through an internal
>> mail relay). so we have set the Mail Gateway up in our remotedelivery
>> mailet.
>>
>> org.apache.james.transport.**mailets.RemoteDeliverydeliver.**deliver(Mail
>> mail,
>> Session session)
>>
>> then in the mailet:
>>
>>             if (gatewayServer == null) {
>>                 MailAddress rcpt = (MailAddress)
>> recipients.iterator().next();
>>                 String host = rcpt.getHost();
>>
>>                 //Lookup the possible targets
>>                 targetServers =
>> getMailetContext().**getSMTPHostAddresses(host);
>>                 if (!targetServers.hasNext()) {
>>                     log("No mail server found for: " + host);
>>                     StringBuffer exceptionBuffer =
>>                         new StringBuffer(128)
>>                         .append("There are no DNS entries for the hostname
>> ")
>>                         .append(host)
>>                         .append(".  I cannot determine where to send this
>> message.");
>>                     return failMessage(mail, new
>> MessagingException(**exceptionBuffer.toString()), false);
>>                 }
>>             } else {
>>                 targetServers = getGatewaySMTPHostAddresses(**
>> gatewayServer);
>>             }
>>
>> we have a gateway server so it goes into the else clause of this block,
>> because it doesn't have to find the mail servers responsible for the
>> domains of the recipients, and it just calls
>> getGatewaySMTPHostAddresses(**gatewayServer);
>>
>> which returns an iterator that just loops through
>>
>> final InetAddress[] ips =
>> org.apache.james.dnsserver.**DNSServer.getAllByName(**nextGateway);
>>
>> which are just all the DNS entries (not MX records) for the gateway
>> server.
>>
>> This is why when i turned up logging to DEBUG on the DNSServer component,
>> i
>> didn't get any meaningful data.
>>
>> So it looks like i have a requirement that i still want MX records to be
>> evaluated while using a mail gateway. Does that make sense?
>>
>> Could i just change this block of code to always call the
>>
>> //Lookup the possible targets
>>                 targetServers =
>> getMailetContext().**getSMTPHostAddresses(host);
>>
>> method?
>>
>> Or?
>>
>> Thoughts?
>>
>> Cole
>>
>>
>>
>> On Thu, May 10, 2012 at 3:40 AM, Eric Charles<er...@apache.org>  wrote:
>>
>>  Quick addon if finally the issue is in james code, and further to Ioan's
>>> point on JIRA, the patch to backport on 2.3 could be
>>>
>>> http://svn.apache.org/viewvc/****james/server/trunk/**dnsservice-**<http://svn.apache.org/viewvc/**james/server/trunk/dnsservice-**>
>>> dnsjava/src/main/java/org/****apache/james/dnsservice/**
>>> dnsjava/DNSJavaService.java?****r1=1035437&r2=1035436&pathrev=**
>>> **1035437<http://svn.apache.**org/viewvc/james/server/trunk/**
>>> dnsservice-dnsjava/src/main/**java/org/apache/james/**
>>> dnsservice/dnsjava/**DNSJavaService.java?r1=**
>>> 1035437&r2=1035436&pathrev=**1035437<http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?r1=1035437&r2=1035436&pathrev=1035437>
>>> >
>>>
>>>
>>> Thx, Eric
>>>
>>>
>>> On 05/10/2012 11:30 AM, Stefano Bagnara wrote:
>>>
>>>  2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>>>
>>>>  Recycle of James did not work, it is still equally using all 6 of the
>>>>> mail
>>>>> servers, even though they are at a different preference levels.
>>>>>
>>>>> Any Ideas?
>>>>>
>>>>>
>>>> I think you have issues at DNS level.
>>>>
>>>> AFAIK james 2.3 had some bug in MX ordering but I remember only two of
>>>> them, and they do not break priority the way you see.
>>>> 1) If james is a relay server for a domain it doesn't take care to
>>>> only relay to "lower priority" servers resulting into loops if the
>>>> high priority servers are not available (this is not your case).
>>>> 2) James does sort MX hosts, but uses a comparator that is not
>>>> "consistent with equals"
>>>> (http://docs.oracle.com/****javase/1.4.2/docs/api/java/**<http://docs.oracle.com/**javase/1.4.2/docs/api/java/**>
>>>> util/Comparator.html<http://**docs.oracle.com/javase/1.4.2/**
>>>> docs/api/java/util/Comparator.**html<http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html>
>>>> >
>>>>
>>>> ).
>>>> This is not necessarily a bad thing as it will correctly sort results
>>>> using the priority but often will return servers with the same
>>>> priority "not shuffled": more often than not, MX are already shuffled
>>>> on the DNS side so this doesn't have a big impact (and is not your
>>>> case).
>>>>
>>>> So check what DNS servers your james is using and make sure that very
>>>> specific DNS servers have updated informations.
>>>>
>>>> Stefano
>>>>
>>>>  Cole
>>>>
>>>>>
>>>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>
>>>>>  wrote:
>>>>>
>>>>>  talking with our internal mail system people, all 6 servers had a
>>>>>
>>>>>> priority
>>>>>> of 10 the last time apache James was restarted.
>>>>>>
>>>>>> Does James cache this data for the life of it running? or is there a
>>>>>> time
>>>>>> to live? or?
>>>>>>
>>>>>> I will schedule a recycle of james to see if it stops using the
>>>>>> servers
>>>>>> that now have a lower preference.
>>>>>>
>>>>>> Let me know if you have any ideas in the mean time.
>>>>>>
>>>>>> Cole
>>>>>>
>>>>>>
>>>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>
>>>>>>  wrote:
>>>>>>
>>>>>>  We have an internal mail system that has 6 MX records 3 at priority
>>>>>> 10
>>>>>>
>>>>>>> (new servers recently added) and 3 at priority 20 (old servers that
>>>>>>> where
>>>>>>> previously at 10).
>>>>>>>
>>>>>>> and it appears that apache james 2.3 is sending mail to all of them
>>>>>>> about
>>>>>>> equally?
>>>>>>>
>>>>>>> i was instructed that it should only connect to the 20's when all of
>>>>>>> the
>>>>>>> 10s are unavailable?
>>>>>>>
>>>>>>> any help would be appreciated?
>>>>>>>
>>>>>>> (or is there any need to restart James? aka, how long does it cache
>>>>>>> its
>>>>>>> data about the MX preferences?)
>>>>>>>
>>>>>>> Cole
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>  ------------------------------****----------------------------**
>>>> --**---------
>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.****apache.org<
>>>> server-user-**unsubscribe@james.apache.org<se...@james.apache.org>
>>>> >
>>>> For additional commands, e-mail: server-user-help@james.apache.****org<
>>>> server-user-help@james.**apache.org <se...@james.apache.org>
>>>> >
>>>>
>>>>
>>>>  --
>>> eric | http://about.echarles.net | @echarles
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: server-user-unsubscribe@james.****apache.org<
>>> server-user-**unsubscribe@james.apache.org<se...@james.apache.org>
>>> >
>>> For additional commands, e-mail: server-user-help@james.apache.****org<
>>> server-user-help@james.**apache.org <se...@james.apache.org>>
>>>
>>>
>>>
>>
> --
> eric | http://about.echarles.net | @echarles
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
> For additional commands, e-mail: server-user-help@james.apache.**org<se...@james.apache.org>
>
>

Re: MX record peference not being honored?

Posted by Eric Charles <er...@apache.org>.
If you specify explicitly a mail gateway, MX record usage does not make 
any sense.

You must see the mail gateway you define as 'hard-coding' the MTA you 
want to use, that skips any usage of dynamically defined MX record.

Thx, Eric

On 05/10/2012 06:28 PM, Cole Ferrier wrote:
> Ahh, i think i've figured out the problem..
>
> We have a requirement to smarthost (transfer all mail through an internal
> mail relay). so we have set the Mail Gateway up in our remotedelivery
> mailet.
>
> org.apache.james.transport.mailets.RemoteDeliverydeliver.deliver(Mail mail,
> Session session)
>
> then in the mailet:
>
>              if (gatewayServer == null) {
>                  MailAddress rcpt = (MailAddress)
> recipients.iterator().next();
>                  String host = rcpt.getHost();
>
>                  //Lookup the possible targets
>                  targetServers =
> getMailetContext().getSMTPHostAddresses(host);
>                  if (!targetServers.hasNext()) {
>                      log("No mail server found for: " + host);
>                      StringBuffer exceptionBuffer =
>                          new StringBuffer(128)
>                          .append("There are no DNS entries for the hostname
> ")
>                          .append(host)
>                          .append(".  I cannot determine where to send this
> message.");
>                      return failMessage(mail, new
> MessagingException(exceptionBuffer.toString()), false);
>                  }
>              } else {
>                  targetServers = getGatewaySMTPHostAddresses(gatewayServer);
>              }
>
> we have a gateway server so it goes into the else clause of this block,
> because it doesn't have to find the mail servers responsible for the
> domains of the recipients, and it just calls
> getGatewaySMTPHostAddresses(gatewayServer);
>
> which returns an iterator that just loops through
>
> final InetAddress[] ips =
> org.apache.james.dnsserver.DNSServer.getAllByName(nextGateway);
>
> which are just all the DNS entries (not MX records) for the gateway server.
>
> This is why when i turned up logging to DEBUG on the DNSServer component, i
> didn't get any meaningful data.
>
> So it looks like i have a requirement that i still want MX records to be
> evaluated while using a mail gateway. Does that make sense?
>
> Could i just change this block of code to always call the
>
> //Lookup the possible targets
>                  targetServers =
> getMailetContext().getSMTPHostAddresses(host);
>
> method?
>
> Or?
>
> Thoughts?
>
> Cole
>
>
>
> On Thu, May 10, 2012 at 3:40 AM, Eric Charles<er...@apache.org>  wrote:
>
>> Quick addon if finally the issue is in james code, and further to Ioan's
>> point on JIRA, the patch to backport on 2.3 could be
>>
>> http://svn.apache.org/viewvc/**james/server/trunk/dnsservice-**
>> dnsjava/src/main/java/org/**apache/james/dnsservice/**
>> dnsjava/DNSJavaService.java?**r1=1035437&r2=1035436&pathrev=**1035437<http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?r1=1035437&r2=1035436&pathrev=1035437>
>>
>> Thx, Eric
>>
>>
>> On 05/10/2012 11:30 AM, Stefano Bagnara wrote:
>>
>>> 2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>>
>>>> Recycle of James did not work, it is still equally using all 6 of the
>>>> mail
>>>> servers, even though they are at a different preference levels.
>>>>
>>>> Any Ideas?
>>>>
>>>
>>> I think you have issues at DNS level.
>>>
>>> AFAIK james 2.3 had some bug in MX ordering but I remember only two of
>>> them, and they do not break priority the way you see.
>>> 1) If james is a relay server for a domain it doesn't take care to
>>> only relay to "lower priority" servers resulting into loops if the
>>> high priority servers are not available (this is not your case).
>>> 2) James does sort MX hosts, but uses a comparator that is not
>>> "consistent with equals"
>>> (http://docs.oracle.com/**javase/1.4.2/docs/api/java/**
>>> util/Comparator.html<http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html>
>>> ).
>>> This is not necessarily a bad thing as it will correctly sort results
>>> using the priority but often will return servers with the same
>>> priority "not shuffled": more often than not, MX are already shuffled
>>> on the DNS side so this doesn't have a big impact (and is not your
>>> case).
>>>
>>> So check what DNS servers your james is using and make sure that very
>>> specific DNS servers have updated informations.
>>>
>>> Stefano
>>>
>>>   Cole
>>>>
>>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>
>>>>   wrote:
>>>>
>>>>   talking with our internal mail system people, all 6 servers had a
>>>>> priority
>>>>> of 10 the last time apache James was restarted.
>>>>>
>>>>> Does James cache this data for the life of it running? or is there a
>>>>> time
>>>>> to live? or?
>>>>>
>>>>> I will schedule a recycle of james to see if it stops using the servers
>>>>> that now have a lower preference.
>>>>>
>>>>> Let me know if you have any ideas in the mean time.
>>>>>
>>>>> Cole
>>>>>
>>>>>
>>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>
>>>>>   wrote:
>>>>>
>>>>>   We have an internal mail system that has 6 MX records 3 at priority 10
>>>>>> (new servers recently added) and 3 at priority 20 (old servers that
>>>>>> where
>>>>>> previously at 10).
>>>>>>
>>>>>> and it appears that apache james 2.3 is sending mail to all of them
>>>>>> about
>>>>>> equally?
>>>>>>
>>>>>> i was instructed that it should only connect to the 20's when all of
>>>>>> the
>>>>>> 10s are unavailable?
>>>>>>
>>>>>> any help would be appreciated?
>>>>>>
>>>>>> (or is there any need to restart James? aka, how long does it cache its
>>>>>> data about the MX preferences?)
>>>>>>
>>>>>> Cole
>>>>>>
>>>>>>
>>>>>
>>>>>
>>> ------------------------------**------------------------------**---------
>>> To unsubscribe, e-mail: server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
>>> For additional commands, e-mail: server-user-help@james.apache.**org<se...@james.apache.org>
>>>
>>>
>> --
>> eric | http://about.echarles.net | @echarles
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
>> For additional commands, e-mail: server-user-help@james.apache.**org<se...@james.apache.org>
>>
>>
>

-- 
eric | http://about.echarles.net | @echarles

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


Re: MX record peference not being honored?

Posted by Cole Ferrier <co...@coleferrier.com>.
Ahh, i think i've figured out the problem..

We have a requirement to smarthost (transfer all mail through an internal
mail relay). so we have set the Mail Gateway up in our remotedelivery
mailet.

org.apache.james.transport.mailets.RemoteDeliverydeliver.deliver(Mail mail,
Session session)

then in the mailet:

            if (gatewayServer == null) {
                MailAddress rcpt = (MailAddress)
recipients.iterator().next();
                String host = rcpt.getHost();

                //Lookup the possible targets
                targetServers =
getMailetContext().getSMTPHostAddresses(host);
                if (!targetServers.hasNext()) {
                    log("No mail server found for: " + host);
                    StringBuffer exceptionBuffer =
                        new StringBuffer(128)
                        .append("There are no DNS entries for the hostname
")
                        .append(host)
                        .append(".  I cannot determine where to send this
message.");
                    return failMessage(mail, new
MessagingException(exceptionBuffer.toString()), false);
                }
            } else {
                targetServers = getGatewaySMTPHostAddresses(gatewayServer);
            }

we have a gateway server so it goes into the else clause of this block,
because it doesn't have to find the mail servers responsible for the
domains of the recipients, and it just calls
getGatewaySMTPHostAddresses(gatewayServer);

which returns an iterator that just loops through

final InetAddress[] ips =
org.apache.james.dnsserver.DNSServer.getAllByName(nextGateway);

which are just all the DNS entries (not MX records) for the gateway server.

This is why when i turned up logging to DEBUG on the DNSServer component, i
didn't get any meaningful data.

So it looks like i have a requirement that i still want MX records to be
evaluated while using a mail gateway. Does that make sense?

Could i just change this block of code to always call the

//Lookup the possible targets
                targetServers =
getMailetContext().getSMTPHostAddresses(host);

method?

Or?

Thoughts?

Cole



On Thu, May 10, 2012 at 3:40 AM, Eric Charles <er...@apache.org> wrote:

> Quick addon if finally the issue is in james code, and further to Ioan's
> point on JIRA, the patch to backport on 2.3 could be
>
> http://svn.apache.org/viewvc/**james/server/trunk/dnsservice-**
> dnsjava/src/main/java/org/**apache/james/dnsservice/**
> dnsjava/DNSJavaService.java?**r1=1035437&r2=1035436&pathrev=**1035437<http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?r1=1035437&r2=1035436&pathrev=1035437>
>
> Thx, Eric
>
>
> On 05/10/2012 11:30 AM, Stefano Bagnara wrote:
>
>> 2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>>
>>> Recycle of James did not work, it is still equally using all 6 of the
>>> mail
>>> servers, even though they are at a different preference levels.
>>>
>>> Any Ideas?
>>>
>>
>> I think you have issues at DNS level.
>>
>> AFAIK james 2.3 had some bug in MX ordering but I remember only two of
>> them, and they do not break priority the way you see.
>> 1) If james is a relay server for a domain it doesn't take care to
>> only relay to "lower priority" servers resulting into loops if the
>> high priority servers are not available (this is not your case).
>> 2) James does sort MX hosts, but uses a comparator that is not
>> "consistent with equals"
>> (http://docs.oracle.com/**javase/1.4.2/docs/api/java/**
>> util/Comparator.html<http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html>
>> ).
>> This is not necessarily a bad thing as it will correctly sort results
>> using the priority but often will return servers with the same
>> priority "not shuffled": more often than not, MX are already shuffled
>> on the DNS side so this doesn't have a big impact (and is not your
>> case).
>>
>> So check what DNS servers your james is using and make sure that very
>> specific DNS servers have updated informations.
>>
>> Stefano
>>
>>  Cole
>>>
>>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>
>>>  wrote:
>>>
>>>  talking with our internal mail system people, all 6 servers had a
>>>> priority
>>>> of 10 the last time apache James was restarted.
>>>>
>>>> Does James cache this data for the life of it running? or is there a
>>>> time
>>>> to live? or?
>>>>
>>>> I will schedule a recycle of james to see if it stops using the servers
>>>> that now have a lower preference.
>>>>
>>>> Let me know if you have any ideas in the mean time.
>>>>
>>>> Cole
>>>>
>>>>
>>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>
>>>>  wrote:
>>>>
>>>>  We have an internal mail system that has 6 MX records 3 at priority 10
>>>>> (new servers recently added) and 3 at priority 20 (old servers that
>>>>> where
>>>>> previously at 10).
>>>>>
>>>>> and it appears that apache james 2.3 is sending mail to all of them
>>>>> about
>>>>> equally?
>>>>>
>>>>> i was instructed that it should only connect to the 20's when all of
>>>>> the
>>>>> 10s are unavailable?
>>>>>
>>>>> any help would be appreciated?
>>>>>
>>>>> (or is there any need to restart James? aka, how long does it cache its
>>>>> data about the MX preferences?)
>>>>>
>>>>> Cole
>>>>>
>>>>>
>>>>
>>>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
>> For additional commands, e-mail: server-user-help@james.apache.**org<se...@james.apache.org>
>>
>>
> --
> eric | http://about.echarles.net | @echarles
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: server-user-unsubscribe@james.**apache.org<se...@james.apache.org>
> For additional commands, e-mail: server-user-help@james.apache.**org<se...@james.apache.org>
>
>

Re: MX record peference not being honored?

Posted by Eric Charles <er...@apache.org>.
Quick addon if finally the issue is in james code, and further to Ioan's 
point on JIRA, the patch to backport on 2.3 could be

http://svn.apache.org/viewvc/james/server/trunk/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java?r1=1035437&r2=1035436&pathrev=1035437

Thx, Eric

On 05/10/2012 11:30 AM, Stefano Bagnara wrote:
> 2012/5/9 Cole Ferrier<co...@coleferrier.com>:
>> Recycle of James did not work, it is still equally using all 6 of the mail
>> servers, even though they are at a different preference levels.
>>
>> Any Ideas?
>
> I think you have issues at DNS level.
>
> AFAIK james 2.3 had some bug in MX ordering but I remember only two of
> them, and they do not break priority the way you see.
> 1) If james is a relay server for a domain it doesn't take care to
> only relay to "lower priority" servers resulting into loops if the
> high priority servers are not available (this is not your case).
> 2) James does sort MX hosts, but uses a comparator that is not
> "consistent with equals"
> (http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html).
> This is not necessarily a bad thing as it will correctly sort results
> using the priority but often will return servers with the same
> priority "not shuffled": more often than not, MX are already shuffled
> on the DNS side so this doesn't have a big impact (and is not your
> case).
>
> So check what DNS servers your james is using and make sure that very
> specific DNS servers have updated informations.
>
> Stefano
>
>> Cole
>>
>> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier<co...@coleferrier.com>  wrote:
>>
>>> talking with our internal mail system people, all 6 servers had a priority
>>> of 10 the last time apache James was restarted.
>>>
>>> Does James cache this data for the life of it running? or is there a time
>>> to live? or?
>>>
>>> I will schedule a recycle of james to see if it stops using the servers
>>> that now have a lower preference.
>>>
>>> Let me know if you have any ideas in the mean time.
>>>
>>> Cole
>>>
>>>
>>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier<co...@coleferrier.com>  wrote:
>>>
>>>> We have an internal mail system that has 6 MX records 3 at priority 10
>>>> (new servers recently added) and 3 at priority 20 (old servers that where
>>>> previously at 10).
>>>>
>>>> and it appears that apache james 2.3 is sending mail to all of them about
>>>> equally?
>>>>
>>>> i was instructed that it should only connect to the 20's when all of the
>>>> 10s are unavailable?
>>>>
>>>> any help would be appreciated?
>>>>
>>>> (or is there any need to restart James? aka, how long does it cache its
>>>> data about the MX preferences?)
>>>>
>>>> Cole
>>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>

-- 
eric | http://about.echarles.net | @echarles

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


Re: MX record peference not being honored?

Posted by Stefano Bagnara <ap...@bago.org>.
2012/5/9 Cole Ferrier <co...@coleferrier.com>:
> Recycle of James did not work, it is still equally using all 6 of the mail
> servers, even though they are at a different preference levels.
>
> Any Ideas?

I think you have issues at DNS level.

AFAIK james 2.3 had some bug in MX ordering but I remember only two of
them, and they do not break priority the way you see.
1) If james is a relay server for a domain it doesn't take care to
only relay to "lower priority" servers resulting into loops if the
high priority servers are not available (this is not your case).
2) James does sort MX hosts, but uses a comparator that is not
"consistent with equals"
(http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Comparator.html).
This is not necessarily a bad thing as it will correctly sort results
using the priority but often will return servers with the same
priority "not shuffled": more often than not, MX are already shuffled
on the DNS side so this doesn't have a big impact (and is not your
case).

So check what DNS servers your james is using and make sure that very
specific DNS servers have updated informations.

Stefano

> Cole
>
> On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier <co...@coleferrier.com> wrote:
>
>> talking with our internal mail system people, all 6 servers had a priority
>> of 10 the last time apache James was restarted.
>>
>> Does James cache this data for the life of it running? or is there a time
>> to live? or?
>>
>> I will schedule a recycle of james to see if it stops using the servers
>> that now have a lower preference.
>>
>> Let me know if you have any ideas in the mean time.
>>
>> Cole
>>
>>
>> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier <co...@coleferrier.com> wrote:
>>
>>> We have an internal mail system that has 6 MX records 3 at priority 10
>>> (new servers recently added) and 3 at priority 20 (old servers that where
>>> previously at 10).
>>>
>>> and it appears that apache james 2.3 is sending mail to all of them about
>>> equally?
>>>
>>> i was instructed that it should only connect to the 20's when all of the
>>> 10s are unavailable?
>>>
>>> any help would be appreciated?
>>>
>>> (or is there any need to restart James? aka, how long does it cache its
>>> data about the MX preferences?)
>>>
>>> Cole
>>>
>>
>>

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


Re: MX record peference not being honored?

Posted by Cole Ferrier <co...@coleferrier.com>.
Recycle of James did not work, it is still equally using all 6 of the mail
servers, even though they are at a different preference levels.

Any Ideas?

Cole

On Tue, May 8, 2012 at 3:03 PM, Cole Ferrier <co...@coleferrier.com> wrote:

> talking with our internal mail system people, all 6 servers had a priority
> of 10 the last time apache James was restarted.
>
> Does James cache this data for the life of it running? or is there a time
> to live? or?
>
> I will schedule a recycle of james to see if it stops using the servers
> that now have a lower preference.
>
> Let me know if you have any ideas in the mean time.
>
> Cole
>
>
> On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier <co...@coleferrier.com> wrote:
>
>> We have an internal mail system that has 6 MX records 3 at priority 10
>> (new servers recently added) and 3 at priority 20 (old servers that where
>> previously at 10).
>>
>> and it appears that apache james 2.3 is sending mail to all of them about
>> equally?
>>
>> i was instructed that it should only connect to the 20's when all of the
>> 10s are unavailable?
>>
>> any help would be appreciated?
>>
>> (or is there any need to restart James? aka, how long does it cache its
>> data about the MX preferences?)
>>
>> Cole
>>
>
>

Re: MX record peference not being honored?

Posted by Cole Ferrier <co...@coleferrier.com>.
talking with our internal mail system people, all 6 servers had a priority
of 10 the last time apache James was restarted.

Does James cache this data for the life of it running? or is there a time
to live? or?

I will schedule a recycle of james to see if it stops using the servers
that now have a lower preference.

Let me know if you have any ideas in the mean time.

Cole

On Tue, May 8, 2012 at 9:42 AM, Cole Ferrier <co...@coleferrier.com> wrote:

> We have an internal mail system that has 6 MX records 3 at priority 10
> (new servers recently added) and 3 at priority 20 (old servers that where
> previously at 10).
>
> and it appears that apache james 2.3 is sending mail to all of them about
> equally?
>
> i was instructed that it should only connect to the 20's when all of the
> 10s are unavailable?
>
> any help would be appreciated?
>
> (or is there any need to restart James? aka, how long does it cache its
> data about the MX preferences?)
>
> Cole
>