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 Daniel Perry <d....@netcase.co.uk> on 2004/10/12 12:52:38 UTC

failover configuration

Hi,
I've got two james servers, and have been asked to set them up as failover
for eachother.

I found the example of the failover in the wiki:
      <mailet match="HostIs=myfoo.com" class="RemoteDelivery">
       <outgoing> file://var/mail/relay/ </outgoing>
       <delayTime> 21600000 </delayTime>
       <maxRetries> 5 </maxRetries>
       <deliveryThreads> 1 </deliveryThreads>
       <gateway> int.myfoo.com </gateway>
       <gatewayPort>25</gatewayPort>
      </mailet>

However this example requires adding a mailet for each domain, which isnt
going to be feasible.

Adding a mailet for each server is an option, but i am not sure how to do
this.  Here are my thoughts:

I am using a customised version of james which uses the VirtualUserTable to
recognise domains as local, rather than the manually entering every domain
in the "servernames" block.  I could add to this code to use another table
that contains columns: (mailservername, domain).  This way the messages will
be accepted and wont request authorisation.

Now for delivery: as the domains that will be relayed will be treated as
local, they must be processed before they are delievered locally (or rather
rejected with no such user error).

So, first thing on the transport block add a mailet:

<mailet match="FailoverForServer=blah.com" class="RemoteDelivery">
       <outgoing> file://var/mail/failoverrelayblah/ </outgoing>
       <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>
       <gateway> blah.com </gateway>
       <gatewayPort>25</gatewayPort>
      </mailet>

The FailOverForServer matcher will look in my new table and check if the
domain that the email is for is listed, and if it's mailserver matched the
parameter.

Would this work?  Has anyone already done this?  Is there an easier way?

An alternative hack i thought of would be to make the changes so that mail
is accepted for the domains based on a table, and then use a matcher that
checks for the highest priority mail server: ie: HighestMX=blah.com, and
deliver that mail to blah.com.

Daniel.


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


Re: Reading mails with UTF-8 charset-encoding

Posted by tobe <to...@swipnet.se>.
I may be wrong here since I don't know exactly what you are doing, but 
if you get an InputStream from the message, that consists of raw bytes 
which have to be decoded. There is a system property, file.encoding 
which controls the default encoding used on your system. There is also a 
javamail property that kicks in for this, I forget what it is but it can 
be found in the javax.mail documentation.

In this case I would rather recommend you to control the decoding 
yourself, looking at the content-type header for the encoding and using 
the java.nio Decoders.

/tobe

Jose Andres Perez wrote:

> Hi,
>
> I want to read the mail content I received in my mailet. I run it in 
> James 2.2.0. The mail content I receive from outside is UTF-8, but 
> when I try to read mail data I do not get the original. For example, 
> if the original mail has the following format
>
> FROM: myaccount@mydomain.com
> TO: youraccount@mydomain.com
> SUBJECT: ññ ??
> BODY: ññ ??
>
> I get the following:
>
> FROM: myaccount@mydomain.com
> TO: youraccount@mydomain.com
> MAIL CONTENT-TYPE: text/plain; charset=UTF-8; format=flowed
> SUBJECT: ññ ??
> BODY: ?? ??
>
> Do you know how could I read the subject and body geting the original 
> text? Do you know if this is a bug of James 2.2.0 version?
>
> Cheers,
> Jose
>
>
>
> ---------------------------------------------------------------------
> 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: Reading mails with UTF-8 charset-encoding

Posted by Jose Andres Perez <jo...@m-centric.com>.
Sorry, :(
The returned mail content is the following and not the one in previous 
mail.

FROM: myaccount@mydomain.com
TO: youraccount@mydomain.com
MAIL CONTENT-TYPE: text/plain; charset=UTF-8; format=flowed
SUBJECT: ?? ??
BODY: ?? ??


Any idea?
Thanks,
jose



Jose Andres Perez wrote:

> Hi,
>
> I want to read the mail content I received in my mailet. I run it in 
> James 2.2.0. The mail content I receive from outside is UTF-8, but 
> when I try to read mail data I do not get the original. For example, 
> if the original mail has the following format
>
> FROM: myaccount@mydomain.com
> TO: youraccount@mydomain.com
> SUBJECT: ññ ??
> BODY: ññ ??
>
> I get the following:
>
> FROM: myaccount@mydomain.com
> TO: youraccount@mydomain.com
> MAIL CONTENT-TYPE: text/plain; charset=UTF-8; format=flowed
> SUBJECT: ññ ??
> BODY: ?? ??
>
> Do you know how could I read the subject and body geting the original 
> text? Do you know if this is a bug of James 2.2.0 version?
>
> Cheers,
> Jose
>
>
>
> ---------------------------------------------------------------------
> 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


Reading mails with UTF-8 charset-encoding

Posted by Jose Andres Perez <jo...@m-centric.com>.
Hi,

I want to read the mail content I received in my mailet. I run it in 
James 2.2.0. The mail content I receive from outside is UTF-8, but when 
I try to read mail data I do not get the original. For example, if the 
original mail has the following format

FROM: myaccount@mydomain.com
TO: youraccount@mydomain.com
SUBJECT: ññ ??
BODY: ññ ??

I get the following:

FROM: myaccount@mydomain.com
TO: youraccount@mydomain.com
MAIL CONTENT-TYPE: text/plain; charset=UTF-8; format=flowed
SUBJECT: ññ ??
BODY: ?? ??

Do you know how could I read the subject and body geting the original 
text? Do you know if this is a bug of James 2.2.0 version?

Cheers,
Jose



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


Matchers for local addresses (Was: failover configuration)

Posted by Daniel Perry <d....@netcase.co.uk>.
I was looking at this stuff again, and was wondering if there isnt a better
way to pick mail out as being 'for this machine' and dont use authorisation
or 'for a remote host' and use authorisation.

My thoughts are that maybe something similar to the existing matchers should
be used in an 'openrelay' block instead of having the servernames /
authorisation blocks.

So, for a simple setup you have somthing like match="HostIs=mydomain.com or
HostIs=myotherdomain".

Or you can have match="HostIsInDBTable=db://maildb/VirtualUserTable?domain"
which uses the database approach, and provides neater configuration than the
hack i currently use.

Going with this, you could then write any matchers you want.  You could add
ip address matchers that allow relaying without authentication for certain
ips.

This appears to be a lot more flexible than the current static approach,
which relies on java code hacks to get round it's limitations!

Daniel.



> -----Original Message-----
> From: Daniel Perry [mailto:d.perry@netcase.co.uk]
> Sent: 12 October 2004 11:53
> To: James Users List
> Subject: failover configuration
>
>
> Hi,
> I've got two james servers, and have been asked to set them up as failover
> for eachother.
>
> I found the example of the failover in the wiki:
>       <mailet match="HostIs=myfoo.com" class="RemoteDelivery">
>        <outgoing> file://var/mail/relay/ </outgoing>
>        <delayTime> 21600000 </delayTime>
>        <maxRetries> 5 </maxRetries>
>        <deliveryThreads> 1 </deliveryThreads>
>        <gateway> int.myfoo.com </gateway>
>        <gatewayPort>25</gatewayPort>
>       </mailet>
>
> However this example requires adding a mailet for each domain, which isnt
> going to be feasible.
>
> Adding a mailet for each server is an option, but i am not sure how to do
> this.  Here are my thoughts:
>
> I am using a customised version of james which uses the
> VirtualUserTable to
> recognise domains as local, rather than the manually entering every domain
> in the "servernames" block.  I could add to this code to use another table
> that contains columns: (mailservername, domain).  This way the
> messages will
> be accepted and wont request authorisation.
>
> Now for delivery: as the domains that will be relayed will be treated as
> local, they must be processed before they are delievered locally
> (or rather
> rejected with no such user error).
>
> So, first thing on the transport block add a mailet:
>
> <mailet match="FailoverForServer=blah.com" class="RemoteDelivery">
>        <outgoing> file://var/mail/failoverrelayblah/ </outgoing>
>        <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>
>        <gateway> blah.com </gateway>
>        <gatewayPort>25</gatewayPort>
>       </mailet>
>
> The FailOverForServer matcher will look in my new table and check if the
> domain that the email is for is listed, and if it's mailserver matched the
> parameter.
>
> Would this work?  Has anyone already done this?  Is there an easier way?
>
> An alternative hack i thought of would be to make the changes so that mail
> is accepted for the domains based on a table, and then use a matcher that
> checks for the highest priority mail server: ie: HighestMX=blah.com, and
> deliver that mail to blah.com.
>
> Daniel.
>
>
> ---------------------------------------------------------------------
> 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