You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Norman Maurer <nm...@spam-box.de> on 2006/02/02 11:49:55 UTC

Get the current recip

Hi guys,

im working on a mailet whicht use the domain of the recips as an option
that is pass to a programm on the commandline. The Server is used as
relay so it sppol the message for each recip .. right ?

So how can i get the current recip for which the message is spooled ?

thx guys for this greate email server


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


Re: Get the current recip

Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer wrote:
> Hi guys,
> 
> im working on a mailet whicht use the domain of the recips as an option
> that is pass to a programm on the commandline. The Server is used as
> relay so it sppol the message for each recip .. right ?

No, each message will have multiple recipients: James split the message
only if a matcher return a partial match.

> So how can i get the current recip for which the message is spooled ?


There are multiple recipients.
Mail.getRecipients() give you the list.

If you have to run a command for each recipient then look to the
"LocalDelivery" or "RemoteDelivery" sources: in their service method
they both loop over the recipients and create multiple messages
(remotedelivery creates a new message for each recipient domain, local
delivery a different message for each recipient).

Stefano


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


Re: Get the current recip

Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer wrote:
> Hi,
> im not sure if you understand what i need to do.. or im not understand
> you ;-)
> 
> we want to use james as relay. I need to set diffrent mailets for
> diffrent domains.. So i need to spool them seperatly. After that i want
> to call diffrent mailets for the recips based on the domain they belong
> to. 
> I thought the split in diffrent spools will be done automaticly when i
> set remotedelivery for the diffrent domains to diffrent spool.


<mailet match="HostIs=domain1.com" class="RemoteDelivery">
	.. remote delivery options ..
</mailet>

<mailet match="HostIs=domain2.com" class="RemoteDelivery">
	.. remote delivery options ..
</mailet>

<mailet match="All" class="RemoteDelivery">
	.. remote delivery options ..
</mailet>

The use the gateway remotedelivery option when appropriate.

Stefano

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


Re: Get the current recip

Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer wrote:
> Thats is what i did.. 
> But when i use mail.getRecipient() to get a array of recips i get all
> recipients but i just want to get the one the mail is spooled for..


I already explained you that there is no such thing! Each spooled mail 
has MULTIPLE recipients. A matcher or a mailet can split a single mail 
with multiple recipients to multiple mail with single recipients, but 
stop thinking that mails in the spool have a single recipient.

If you use HostIs then the mail is automatically splitted and only a new 
mail with only the recipients matching the HostIs domain will run in the 
RemoteDelivery for that matcher, and the remaining recipients will be 
passed to the following HostIs matcher.

Stefano

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


Re: Get the current recip

Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer wrote:
> Ah ok now i understand.. sorry ..
> 
> Just one more question. if i use  these config:
> 
>        <mailet match="HostIs=spam-box.de" class="RemoteDelivery">
>              <outgoing> db://maildb/spool/outgoing1 </outgoing>
>              <delayTime> 21600000 </delayTime>
>              <maxRetries> 5 </maxRetries>
>              <deliveryThreads> 8 </deliveryThreads>
>              <gateway>192.168.0.100 </gateway>
>              <gatewayPort>2525</gatewayPort>
>          </mailet>
> 
>          <mailet match="HostIs=debian-made.de" class="RemoteDelivery">
>              <outgoing> db://maildb/spool/outgoing2 </outgoing>
>              <delayTime> 21600000 </delayTime>
>              <maxRetries> 5 </maxRetries>
>              <deliveryThreads> 8 </deliveryThreads>
>              <gateway>192.168.0.110 </gateway>
>              <gatewayPort>2525</gatewayPort>
> 	</mailet>
> 
> The Email will be splittet for the domains matched HostIs. Right ?
> You  said "the remaining recipients will be passed to the following
> HostIs matcher". So it should split the emails in the 2 RemoteDelivery
> if a email is send to test@spam-box.de and test@debian-made.de .. I
> think the problem is that is happen after the other mailets are
> called .. right ?


The first matcher/mailet will take care of the mails for @spam-box.de.
If a single mail has multiple recipients and only few are for 
@spam-box.de it will split the mails in 2 mails: the first having only 
the @spam-box.de recipients, the second with the remaining recipients. 
The first mail will be sent using the first RemoteDelivery, the second 
mail will continue to HostIs=debian-made.de, so if the recipients are 
@debian-made.de they will be delivered by the second RemoteDelivery. If 
the second matcher doesn't match (recipients with other domains) the 
message continue to the following matcher (you should add a <mailet 
match="All" at the end of your processor). If the mail reach the end of 
the processor with no processing James will send it to the "error" 
processor and will log a configuration error.

Stefano

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


Re: Get the current recip

Posted by Stefano Bagnara <ap...@bago.org>.
Norman Maurer wrote:
> Ah ok so if i want to scan emails per domain and add flags for the
> things i found i should use the message.addHeader and not
> mail.addAttribute right ? mail.addAttribute will add it to all emails
> and mail.addHeader only to the one that get proceed via the mailet...


Why do you need to flag mails for domain?

Please explain what behaviour you need and we'll tell you the best way.

"Header" is a message property and is contained in the message that will 
be delivered, "Attribute" is just an attribute specific to james that 
you can use in your spooling logic or in your mailet logic.
Both Header and Attribute are common to the WHOLE mail, you have to 
split the mail if you need to set different header/attributes per 
recipients!

<mailet match="HostIs=domain1.com" class="SetMailAttribute">
	<attr1>y</attr1>
	<attr2>a</attr2>
</mailet>

<mailet match="HostIs=domain2.com" class="SetMailAttribute">
	<attr1>y</attr1>
	<attr2>a</attr2>
</mailet>

<mailet match="HostIs=domain3.com" class="SetMailAttribute">
	<attr1>x</attr1>
	<attr2>a</attr2>
</mailet>

<mailet match="HostIs=domain4.com" class="SetMailAttribute">
	<attr1>x</attr1>
	<attr2>b</attr2>
</mailet>

<mailet match="HasMailAttributeWithValue=attr2,a" class="DoSomething">
	.....
</mailet>

<mailet match="HasMailAttributeWithValue=attr1,x" class="DoSomethingElse">
	.....
</mailet>

Stefano

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


Re: Get the current recip

Posted by Norman Maurer <nm...@spam-box.de>.
Ah ok so if i want to scan emails per domain and add flags for the
things i found i should use the message.addHeader and not
mail.addAttribute right ? mail.addAttribute will add it to all emails
and mail.addHeader only to the one that get proceed via the mailet...

bye
 
Am Freitag, den 03.02.2006, 11:18 +0100 schrieb Stefano Bagnara:
> Norman Maurer wrote:
> > Ah ok now i understand.. sorry ..
> > 
> > Just one more question. if i use  these config:
> > 
> >        <mailet match="HostIs=spam-box.de" class="RemoteDelivery">
> >              <outgoing> db://maildb/spool/outgoing1 </outgoing>
> >              <delayTime> 21600000 </delayTime>
> >              <maxRetries> 5 </maxRetries>
> >              <deliveryThreads> 8 </deliveryThreads>
> >              <gateway>192.168.0.100 </gateway>
> >              <gatewayPort>2525</gatewayPort>
> >          </mailet>
> > 
> >          <mailet match="HostIs=debian-made.de" class="RemoteDelivery">
> >              <outgoing> db://maildb/spool/outgoing2 </outgoing>
> >              <delayTime> 21600000 </delayTime>
> >              <maxRetries> 5 </maxRetries>
> >              <deliveryThreads> 8 </deliveryThreads>
> >              <gateway>192.168.0.110 </gateway>
> >              <gatewayPort>2525</gatewayPort>
> > 	</mailet>
> > 
> > The Email will be splittet for the domains matched HostIs. Right ?
> > You  said "the remaining recipients will be passed to the following
> > HostIs matcher". So it should split the emails in the 2 RemoteDelivery
> > if a email is send to test@spam-box.de and test@debian-made.de .. I
> > think the problem is that is happen after the other mailets are
> > called .. right ?
> 
> 
> The first matcher/mailet will take care of the mails for @spam-box.de.
> If a single mail has multiple recipients and only few are for 
> @spam-box.de it will split the mails in 2 mails: the first having only 
> the @spam-box.de recipients, the second with the remaining recipients. 
> The first mail will be sent using the first RemoteDelivery, the second 
> mail will continue to HostIs=debian-made.de, so if the recipients are 
> @debian-made.de they will be delivered by the second RemoteDelivery. If 
> the second matcher doesn't match (recipients with other domains) the 
> message continue to the following matcher (you should add a <mailet 
> match="All" at the end of your processor). If the mail reach the end of 
> the processor with no processing James will send it to the "error" 
> processor and will log a configuration error.
> 
> Stefano
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 
> 


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


Re: Get the current recip

Posted by Norman Maurer <nm...@spam-box.de>.
Ah ok now i understand.. sorry ..

Just one more question. if i use  these config:

       <mailet match="HostIs=spam-box.de" class="RemoteDelivery">
             <outgoing> db://maildb/spool/outgoing1 </outgoing>
             <delayTime> 21600000 </delayTime>
             <maxRetries> 5 </maxRetries>
             <deliveryThreads> 8 </deliveryThreads>
             <gateway>192.168.0.100 </gateway>
             <gatewayPort>2525</gatewayPort>
         </mailet>

         <mailet match="HostIs=debian-made.de" class="RemoteDelivery">
             <outgoing> db://maildb/spool/outgoing2 </outgoing>
             <delayTime> 21600000 </delayTime>
             <maxRetries> 5 </maxRetries>
             <deliveryThreads> 8 </deliveryThreads>
             <gateway>192.168.0.110 </gateway>
             <gatewayPort>2525</gatewayPort>
	</mailet>

The Email will be splittet for the domains matched HostIs. Right ?
You  said "the remaining recipients will be passed to the following
HostIs matcher". So it should split the emails in the 2 RemoteDelivery
if a email is send to test@spam-box.de and test@debian-made.de .. I
think the problem is that is happen after the other mailets are
called .. right ?

So if i use HostIs= in the other mailets for each domain it will be
work ?


Sorry for being so dumb :-(

Thx for all your help

bye



Am Donnerstag, den 02.02.2006, 16:27 +0100 schrieb Stefano Bagnara:
> ts. A matcher or a mailet can split a single mail 
> with multiple recipients to multiple mail with single recipients, but 
> stop thinking that mails in the spool have a single recipient.
> 
> If you use HostIs then the mail is automatically splitted and only a
> new 
> mail with only the recipients matching the HostIs domain will run in
> the 
> RemoteDelivery for that matcher, and the remaining recipients will be 
> passed to the following HostIs matcher. 


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


Re: Get the current recip

Posted by Norman Maurer <nm...@spam-box.de>.
Thats is what i did.. 
But when i use mail.getRecipient() to get a array of recips i get all
recipients but i just want to get the one the mail is spooled for..

bye
 
Am Donnerstag, den 02.02.2006, 15:45 +0100 schrieb Stefano Bagnara:
> Norman Maurer wrote:
> > Hi,
> > im not sure if you understand what i need to do.. or im not understand
> > you ;-)
> > 
> > we want to use james as relay. I need to set diffrent mailets for
> > diffrent domains.. So i need to spool them seperatly. After that i want
> > to call diffrent mailets for the recips based on the domain they belong
> > to. 
> > I thought the split in diffrent spools will be done automaticly when i
> > set remotedelivery for the diffrent domains to diffrent spool.
> 
> 
> <mailet match="HostIs=domain1.com" class="RemoteDelivery">
> 	.. remote delivery options ..
> </mailet>
> 
> <mailet match="HostIs=domain2.com" class="RemoteDelivery">
> 	.. remote delivery options ..
> </mailet>
> 
> <mailet match="All" class="RemoteDelivery">
> 	.. remote delivery options ..
> </mailet>
> 
> The use the gateway remotedelivery option when appropriate.
> 
> Stefano
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 
> 


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


Re: Get the current recip

Posted by Norman Maurer <nm...@spam-box.de>.
Hi,
im not sure if you understand what i need to do.. or im not understand
you ;-)

we want to use james as relay. I need to set diffrent mailets for
diffrent domains.. So i need to spool them seperatly. After that i want
to call diffrent mailets for the recips based on the domain they belong
to. 
I thought the split in diffrent spools will be done automaticly when i
set remotedelivery for the diffrent domains to diffrent spool.

bye
Norman


Am Donnerstag, den 02.02.2006, 15:04 +0100 schrieb Stefano Bagnara:
> Norman Maurer wrote:
> > Hi guys,
> > 
> > im working on a mailet whicht use the domain of the recips as an option
> > that is pass to a programm on the commandline. The Server is used as
> > relay so it sppol the message for each recip .. right ?
> 
> No, each message will have multiple recipients: James split the message
> only if a matcher return a partial match.
> 
> > So how can i get the current recip for which the message is spooled ?
> 
> 
> There are multiple recipients.
> Mail.getRecipients() give you the list.
> 
> If you have to run a command for each recipient then look to the
> "LocalDelivery" or "RemoteDelivery" sources: in their service method
> they both loop over the recipients and create multiple messages
> (remotedelivery creates a new message for each recipient domain, local
> delivery a different message for each recipient).
> 
> Stefano
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 
> 


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