I finally solved it.
I changed the RemoteDelivery.java and recompiled James. Finally it's sending
mails from different ips.

Here is what I changed (line 1092 of RemoteDelivery.java) :
if (isBindUsed) {
            // undocumented JavaMail 1.2 feature, smtp transport will use
            // our socket factory, which will also set the local address
            props.put("mail.smtp.localaddress", bindAddress);
            //mail.smtp.localaddr
            /*props.put("mail.smtp.socketFactory.class",

"org.apache.james.transport.mailets.RemoteDeliverySocketFactory");
            // Don't fallback to the standard socket factory on error, do
throw an exception
            props.put("mail.smtp.socketFactory.fallback", "false");*/
        }
Basically I, added *props.put("mail.smtp.localaddress", bindAddress); *and
commented the socketFactory props.

Thanks for your help guys!


On Wed, Sep 24, 2008 at 5:02 AM, Stefano Bagnara <[EMAIL PROTECTED]> wrote:

> Leandro Bertolami ha scritto:
>
>  Stefano,
>>
>> Thanks for your response. I tried removing the bind parameter and adding
>> mail.smtp.localaddr but still cant make it work.
>>
>> Here is the config
>>
>> <mailet match="SubjectIs=xxx.xxx.xxx.91" class="RemoteDelivery">
>>            <outgoing>file://var/mail/outgoing-91/</outgoing>
>>            <mail.smtp.localaddr>xxx.xxx.xxx.91</mail.smtp.localaddr>
>>
>>  <delayTime>  5 minutes </delayTime>
>>            <delayTime> 10 minutes </delayTime>
>>            <delayTime> 45 minutes </delayTime>
>>            <delayTime>  2 hours </delayTime>
>>            <delayTime>  3 hours </delayTime>
>>            <delayTime>  6 hours </delayTime>
>>            <maxRetries> 25 </maxRetries>
>>            <deliveryThreads> 1 </deliveryThreads>
>>            <sendpartial>false</sendpartial>
>>            <bounceProcessor>bounces</bounceProcessor>
>>        </mailet>
>>
>>         <mailet match="SubjectIs=xxx.xxx.xxx.90" class="RemoteDelivery">
>>            <outgoing>file://var/mail/outgoing/</outgoing>
>>            <mail.smtp.localaddr>xxx.xxx.xxx.90</mail.smtp.localaddr>
>>            <delayTime>  5 minutes </delayTime>
>>            <delayTime> 10 minutes </delayTime>
>>            <delayTime> 45 minutes </delayTime>
>>            <delayTime>  2 hours </delayTime>
>>            <delayTime>  3 hours </delayTime>
>>            <delayTime>  6 hours </delayTime>
>>            <maxRetries> 25 </maxRetries>
>>            <deliveryThreads> 1 </deliveryThreads>
>>            <sendpartial>false</sendpartial>
>>            <bounceProcessor>bounces</bounceProcessor>
>>         </mailet>
>>
>> It sends both mails from the .90 IP, but with this config it's working ok
>> (but only for 2 ip's, I tried with 3 but didn work)
>>
>>      <mailet match="SubjectIs=xxx.xxx.xxx.91" class="RemoteDelivery">
>>            <outgoing>file://var/mail/outgoing-91/</outgoing>
>>            <bind>xxx.xxx.xxx.91</bind>
>>            ...
>>         </mailet>
>>
>>
>>         <mailet match="SubjectIs=xxx.xxx.xxx.90" class="RemoteDelivery">
>>            <outgoing>file://var/mail/outgoing/</outgoing>
>>            <mail.smtp.localaddr>xxx.xxx.xxx.90</mail.smtp.localaddr>
>>          ...
>>        </mailet>
>>
>> If I add this to the mailets, the mals for .92 came with the IP .90.
>>
>>  <mailet match="SubjectIs=206.212.241.92" class="RemoteDelivery">
>>            <outgoing> file://var/mail/outgoing-92/ </outgoing>
>>            <mail.smtp.localaddr>206.212.241.92</mail.smtp.localaddr>
>>
>>
>> I think I'm getting closer. Any Ideas?
>>
>> Thanks again for your time!
>>
>
> Hi Leandro,
>
> I just had a fast review of javamail code and it seems that the
> mail.smtp.localaddr configuration should work... BUT
>
> I read in javamail docs that if a mail.smtp.localhost configuration is
> present then it override in some case the mail.smtp.localaddr, and indeed we
> have this code in the RemoteDelivery:
>
>        //Set the hostname we'll use as this server
>        if (getMailetContext().getAttribute(Constants.HELLO_NAME) != null) {
>           props.put("mail.smtp.localhost",
> getMailetContext().getAttribute(Constants.HELLO_NAME));
>        } else {
>            String defaultDomain = (String)
> getMailetContext().getAttribute(Constants.DEFAULT_DOMAIN);
>            if (defaultDomain != null) {
>                props.put("mail.smtp.localhost", defaultDomain);
>            }
>        }
>
> But this mail.smtp.localhost should only be used by javamail for the HELO
> command and not for the IP used as source of the connection.
>
> Javamail uses the com.sun.mail.util.SocketFetcher class to retrieve the
> socket. You could try writing a small test for SocketFetcher to see if it
> correctly uses the bind to the local ip.
>
>
> Stefano
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to