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 Simon Levesque <su...@gmail.com> on 2019/03/04 12:16:56 UTC

How to split a message in a mailet

Hi all,

I created a mailet that modifies some recipients. When modifying them, I
want to add an header only to those modified.
Given the method's signature:

public void service(Mail mail) throws MessagingException {

It looks like I can only modify one mail.

From the documentation, I recal that if one message has 5 recipients, then
they would be splited in 5 messages (one per recipient) and being processed
individually, but in pratice, I am not seing that.
Is there a way to do any of these:

   1. configure something to have one mail per recipient
   2. from a mailet, split a mail in 2 or call a service to create a new
   mail

thanks

Re: How to split a message in a mailet

Posted by Simon Levesque <si...@simonlevesque.com>.
Hi Garry,

My order is:

1-
      <mailet match="All"
class="com.foilen.james.components.mailet.ExactAndCatchAllRedirections">
        <cacheMaxTimeInSeconds>10</cacheMaxTimeInSeconds>
        <cacheMaxEntries>1000</cacheMaxEntries>
      </mailet>

2-
      <mailet match="HasHeader=isRedirection"
class="com.foilen.james.components.mailet.LogInfo">
        <text>Recipient is ExactAndCatchAllRedirections</text>
      </mailet>

3-
<mailet match="All"
class="com.foilen.james.components.mailet.DumpAllSystemErr" />

4-
      <mailet match="HasHeader=isRedirection" class="ToProcessor">
        <processor>auth-user-relay</processor>
      </mailet>

...

1- is the one adding the header per recipients
2- should show, but doesn't
3- Show the logs I provided which shows the header per recipients is well
present
4- not going thru since it is the same check as #2 and #2 is not working



On Wed, 6 Mar 2019 at 15:47, Garry Hurley <ga...@gmail.com> wrote:

> Simon, it might be a question of where you are attaching the header.  In
> the root processor, you need to attach the isRedirection header before your
> email hits the mailet you want to use to route it.  I suggest using a
> multiplerecipients matcher and customizing that to identify when some
> recipients are part of the group you want to add the header to.  Then to
> determine how it should be processed, you have a matcher that checks to see
> if the header is present AND the recipient is part of said group.
> Remember, processor order is important.
>
> On Wed, Mar 6, 2019 at 6:56 AM Simon Levesque <su...@gmail.com> wrote:
>
> > Hi,
> > I added that logic to add an header per recipient, but it is being
> ignored
> > by HasHeader .
> >
> > E.g. in my logs, I can see:
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Recipients]---
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
> > Recipient]---
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com : isRedirection
> > ->
> > true
> >
> > and
> >       <mailet match="HasHeader=isRedirection"
> > class="com.foilen.james.components.mailet.LogInfo">
> >         <text>Recipient is ExactAndCatchAllRedirections</text>
> >       </mailet>
> > is not catching it. If I put the header on the message itself, then it is
> > getting it.
> >
> > Is it a bug in the matcher? Should I use another matcher?
> > thanks
> >
> >
> > On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com> wrote:
> >
> > > Great, i will try that.
> > > Thanks
> > >
> > > Le lun. 4 mars 2019 08:02, Raphael OUAZANA <
> raphael.ouazana@linagora.com
> > >
> > > a écrit :
> > >
> > >> Hi,
> > >>
> > >> Le 2019-03-04 13:16, Simon Levesque a écrit :
> > >> > Hi all,
> > >> >
> > >> > I created a mailet that modifies some recipients. When modifying
> them,
> > >> > I
> > >> > want to add an header only to those modified.
> > >> > Given the method's signature:
> > >> >
> > >> > public void service(Mail mail) throws MessagingException {
> > >> >
> > >> > It looks like I can only modify one mail.
> > >> >
> > >> > From the documentation, I recal that if one message has 5
> recipients,
> > >> > then
> > >> > they would be splited in 5 messages (one per recipient) and being
> > >> > processed
> > >> > individually, but in pratice, I am not seing that.
> > >> > Is there a way to do any of these:
> > >> >
> > >> >    1. configure something to have one mail per recipient
> > >> >    2. from a mailet, split a mail in 2 or call a service to create a
> > >> > new
> > >> >    mail
> > >>
> > >> Something has been added recently exactly for this purpose:
> > >> perRecipientHeaders.
> > >>
> > >> See Mail.addSpecificHeaderForRecipient and
> > >> Mail.getPerRecipientSpecificHeaders.
> > >>
> > >> Regards,
> > >> Raphaël Ouazana.
> > >>
> > >
> >
>

Re: How to split a message in a mailet

Posted by Garry Hurley <ga...@gmail.com>.
Simon, it might be a question of where you are attaching the header.  In
the root processor, you need to attach the isRedirection header before your
email hits the mailet you want to use to route it.  I suggest using a
multiplerecipients matcher and customizing that to identify when some
recipients are part of the group you want to add the header to.  Then to
determine how it should be processed, you have a matcher that checks to see
if the header is present AND the recipient is part of said group.
Remember, processor order is important.

On Wed, Mar 6, 2019 at 6:56 AM Simon Levesque <su...@gmail.com> wrote:

> Hi,
> I added that logic to add an header per recipient, but it is being ignored
> by HasHeader .
>
> E.g. in my logs, I can see:
> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Recipients]---
> INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
> Recipient]---
> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com : isRedirection
> ->
> true
>
> and
>       <mailet match="HasHeader=isRedirection"
> class="com.foilen.james.components.mailet.LogInfo">
>         <text>Recipient is ExactAndCatchAllRedirections</text>
>       </mailet>
> is not catching it. If I put the header on the message itself, then it is
> getting it.
>
> Is it a bug in the matcher? Should I use another matcher?
> thanks
>
>
> On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com> wrote:
>
> > Great, i will try that.
> > Thanks
> >
> > Le lun. 4 mars 2019 08:02, Raphael OUAZANA <raphael.ouazana@linagora.com
> >
> > a écrit :
> >
> >> Hi,
> >>
> >> Le 2019-03-04 13:16, Simon Levesque a écrit :
> >> > Hi all,
> >> >
> >> > I created a mailet that modifies some recipients. When modifying them,
> >> > I
> >> > want to add an header only to those modified.
> >> > Given the method's signature:
> >> >
> >> > public void service(Mail mail) throws MessagingException {
> >> >
> >> > It looks like I can only modify one mail.
> >> >
> >> > From the documentation, I recal that if one message has 5 recipients,
> >> > then
> >> > they would be splited in 5 messages (one per recipient) and being
> >> > processed
> >> > individually, but in pratice, I am not seing that.
> >> > Is there a way to do any of these:
> >> >
> >> >    1. configure something to have one mail per recipient
> >> >    2. from a mailet, split a mail in 2 or call a service to create a
> >> > new
> >> >    mail
> >>
> >> Something has been added recently exactly for this purpose:
> >> perRecipientHeaders.
> >>
> >> See Mail.addSpecificHeaderForRecipient and
> >> Mail.getPerRecipientSpecificHeaders.
> >>
> >> Regards,
> >> Raphaël Ouazana.
> >>
> >
>

Re: How to split a message in a mailet

Posted by Garry Hurley <ga...@gmail.com>.
Long names are not a problem - unless you are a masochist still using a text editor and command-line compilation.

Sent from my iPhone

> On Apr 9, 2019, at 4:56 AM, Raphael OUAZANA <ra...@linagora.com> wrote:
> 
> Hi Simon,
> 
> Thank you very much and sorry for the late reply.
> 
> I see nothing wrong with long names. Here I would just replace Specific by PerRecipient as it is the common naming in James.
> 
> An alternative to your implementation would be to have specific mailets to remove/search PerRecipient headers, and use mailet composability to check both at one time. But I'm fine with your solution, don't hesitate to open a PR for them.
> 
> Thanks,
> Raphaël.
> 
> Le 2019-04-01 22:34, Simon Levesque a écrit :
>> Hi Raphael,
>> I created a matcher and remover that take care of the per recipient
>> headers as well as the global ones. I copied the existing ones (with
>> their tests) and added the use cases for per recipient.
>> They are currently available there:
>>    *
>> https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecific.java
>>    *
>> https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecificTest.java
>>    *
>> https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecific.java
>>    *
>> https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecificTest.java
>> I would like to add them in the James project, so I will create a Jira
>> for them, but I wanted to know what names would you suggest? Mine are
>> pretty long, so I would like to know your thoughts.
>> Thanks
>> On Thu, 7 Mar 2019 at 10:05, Raphael OUAZANA
>> <ra...@linagora.com> wrote:
>>> Hi,
>>> You are right HasHeader does not handle perRecipientHeaders.
>>> I'm not sure of the good solution for this: either you can modify
>>> HasHeader to return a list of recipients depending on
>>> perRecipientHeaders (a.), or you can write an other matcher (b.).
>>> Given the documentation I think (b.) would be more appropriate, but
>>> other advices are very welcome.
>>> Regards,
>>> Raphaël.
>>> Le 2019-03-06 12:55, Simon Levesque a écrit :
>>>> Hi,
>>>> I added that logic to add an header per recipient, but it is being
>>>> ignored by HasHeader .
>>>> E.g. in my logs, I can see:
>>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail -
>>> Recipients]---
>>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
>>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
>>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
>>>> Recipient]---
>>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com :
>>>> isRedirection -> true
>>>> and
>>>> <mailet match="HasHeader=isRedirection"
>>>> class="com.foilen.james.components.mailet.LogInfo">
>>>> <text>Recipient is ExactAndCatchAllRedirections</text>
>>>> </mailet>
>>>> is not catching it. If I put the header on the message itself,
>>> then it
>>>> is getting it.
>>>> Is it a bug in the matcher? Should I use another matcher?
>>>> thanks
>>>> On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com>
>>>> wrote:
>>>>> Great, i will try that.
>>>>> Thanks
>>>>> Le lun. 4 mars 2019 08:02, Raphael OUAZANA
>>>>> <ra...@linagora.com> a écrit :
>>>>>> Hi,
>>>>>> Le 2019-03-04 13:16, Simon Levesque a écrit :
>>>>>>> Hi all,
>>>>>>> I created a mailet that modifies some recipients. When
>>> modifying
>>>>>> them,
>>>>>>> I
>>>>>>> want to add an header only to those modified.
>>>>>>> Given the method's signature:
>>>>>>> public void service(Mail mail) throws MessagingException {
>>>>>>> It looks like I can only modify one mail.
>>>>>>> From the documentation, I recal that if one message has 5
>>>>>> recipients,
>>>>>>> then
>>>>>>> they would be splited in 5 messages (one per recipient) and
>>>>>> being
>>>>>>> processed
>>>>>>> individually, but in pratice, I am not seing that.
>>>>>>> Is there a way to do any of these:
>>>>>>> 1. configure something to have one mail per recipient
>>>>>>> 2. from a mailet, split a mail in 2 or call a service to
>>>>>> create a
>>>>>>> new
>>>>>>> mail
>>>>>> Something has been added recently exactly for this purpose:
>>>>>> perRecipientHeaders.
>>>>>> See Mail.addSpecificHeaderForRecipient and
>>>>>> Mail.getPerRecipientSpecificHeaders.
>>>>>> Regards,
>>>>>> Raphaël Ouazana.
> 
> ---------------------------------------------------------------------
> 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: How to split a message in a mailet

Posted by Simon Levesque <su...@gmail.com>.
Hi Raphael,

no worries for the delais (as you can see I have them too :) ).
I created https://jira.apache.org/jira/browse/JAMES-2735 and will provide
the pull request shortly.

regards

On Tue, 9 Apr 2019 at 04:56, Raphael OUAZANA <ra...@linagora.com>
wrote:

> Hi Simon,
>
> Thank you very much and sorry for the late reply.
>
> I see nothing wrong with long names. Here I would just replace Specific
> by PerRecipient as it is the common naming in James.
>
> An alternative to your implementation would be to have specific mailets
> to remove/search PerRecipient headers, and use mailet composability to
> check both at one time. But I'm fine with your solution, don't hesitate
> to open a PR for them.
>
> Thanks,
> Raphaël.
>
> Le 2019-04-01 22:34, Simon Levesque a écrit :
> > Hi Raphael,
> >
> > I created a matcher and remover that take care of the per recipient
> > headers as well as the global ones. I copied the existing ones (with
> > their tests) and added the use cases for per recipient.
> > They are currently available there:
> >
> >       *
> >
> https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecific.java
> >
> >       *
> >
> https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecificTest.java
> >
> >       *
> >
> https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecific.java
> >
> >       *
> >
> https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecificTest.java
> >
> > I would like to add them in the James project, so I will create a Jira
> > for them, but I wanted to know what names would you suggest? Mine are
> > pretty long, so I would like to know your thoughts.
> >
> > Thanks
> >
> > On Thu, 7 Mar 2019 at 10:05, Raphael OUAZANA
> > <ra...@linagora.com> wrote:
> >
> >> Hi,
> >>
> >> You are right HasHeader does not handle perRecipientHeaders.
> >>
> >> I'm not sure of the good solution for this: either you can modify
> >> HasHeader to return a list of recipients depending on
> >> perRecipientHeaders (a.), or you can write an other matcher (b.).
> >> Given the documentation I think (b.) would be more appropriate, but
> >> other advices are very welcome.
> >>
> >> Regards,
> >> Raphaël.
> >>
> >> Le 2019-03-06 12:55, Simon Levesque a écrit :
> >>> Hi,
> >>> I added that logic to add an header per recipient, but it is being
> >>> ignored by HasHeader .
> >>>
> >>> E.g. in my logs, I can see:
> >>>
> >>> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail -
> >> Recipients]---
> >>> INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
> >>> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
> >>> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
> >>> Recipient]---
> >>> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com :
> >>> isRedirection -> true
> >>>
> >>> and
> >>>
> >>> <mailet match="HasHeader=isRedirection"
> >>> class="com.foilen.james.components.mailet.LogInfo">
> >>> <text>Recipient is ExactAndCatchAllRedirections</text>
> >>> </mailet>
> >>> is not catching it. If I put the header on the message itself,
> >> then it
> >>> is getting it.
> >>>
> >>> Is it a bug in the matcher? Should I use another matcher?
> >>> thanks
> >>>
> >>> On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com>
> >>> wrote:
> >>>
> >>>> Great, i will try that.
> >>>> Thanks
> >>>>
> >>>> Le lun. 4 mars 2019 08:02, Raphael OUAZANA
> >>>> <ra...@linagora.com> a écrit :
> >>>>
> >>>>> Hi,
> >>>>>
> >>>>> Le 2019-03-04 13:16, Simon Levesque a écrit :
> >>>>>> Hi all,
> >>>>>>
> >>>>>> I created a mailet that modifies some recipients. When
> >> modifying
> >>>>> them,
> >>>>>> I
> >>>>>> want to add an header only to those modified.
> >>>>>> Given the method's signature:
> >>>>>>
> >>>>>> public void service(Mail mail) throws MessagingException {
> >>>>>>
> >>>>>> It looks like I can only modify one mail.
> >>>>>>
> >>>>>> From the documentation, I recal that if one message has 5
> >>>>> recipients,
> >>>>>> then
> >>>>>> they would be splited in 5 messages (one per recipient) and
> >>>>> being
> >>>>>> processed
> >>>>>> individually, but in pratice, I am not seing that.
> >>>>>> Is there a way to do any of these:
> >>>>>>
> >>>>>> 1. configure something to have one mail per recipient
> >>>>>> 2. from a mailet, split a mail in 2 or call a service to
> >>>>> create a
> >>>>>> new
> >>>>>> mail
> >>>>>
> >>>>> Something has been added recently exactly for this purpose:
> >>>>> perRecipientHeaders.
> >>>>>
> >>>>> See Mail.addSpecificHeaderForRecipient and
> >>>>> Mail.getPerRecipientSpecificHeaders.
> >>>>>
> >>>>> Regards,
> >>>>> Raphaël Ouazana.
>

Re: How to split a message in a mailet

Posted by Raphael OUAZANA <ra...@linagora.com>.
Hi Simon,

Thank you very much and sorry for the late reply.

I see nothing wrong with long names. Here I would just replace Specific 
by PerRecipient as it is the common naming in James.

An alternative to your implementation would be to have specific mailets 
to remove/search PerRecipient headers, and use mailet composability to 
check both at one time. But I'm fine with your solution, don't hesitate 
to open a PR for them.

Thanks,
Raphaël.

Le 2019-04-01 22:34, Simon Levesque a écrit :
> Hi Raphael,
> 
> I created a matcher and remover that take care of the per recipient
> headers as well as the global ones. I copied the existing ones (with
> their tests) and added the use cases for per recipient.
> They are currently available there:
> 
> 	*
> https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecific.java
> 
> 	*
> https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecificTest.java
> 
> 	*
> https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecific.java
> 
> 	*
> https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecificTest.java
> 
> I would like to add them in the James project, so I will create a Jira
> for them, but I wanted to know what names would you suggest? Mine are
> pretty long, so I would like to know your thoughts.
> 
> Thanks
> 
> On Thu, 7 Mar 2019 at 10:05, Raphael OUAZANA
> <ra...@linagora.com> wrote:
> 
>> Hi,
>> 
>> You are right HasHeader does not handle perRecipientHeaders.
>> 
>> I'm not sure of the good solution for this: either you can modify
>> HasHeader to return a list of recipients depending on
>> perRecipientHeaders (a.), or you can write an other matcher (b.).
>> Given the documentation I think (b.) would be more appropriate, but
>> other advices are very welcome.
>> 
>> Regards,
>> Raphaël.
>> 
>> Le 2019-03-06 12:55, Simon Levesque a écrit :
>>> Hi,
>>> I added that logic to add an header per recipient, but it is being
>>> ignored by HasHeader .
>>> 
>>> E.g. in my logs, I can see:
>>> 
>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail -
>> Recipients]---
>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
>>> Recipient]---
>>> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com :
>>> isRedirection -> true
>>> 
>>> and
>>> 
>>> <mailet match="HasHeader=isRedirection"
>>> class="com.foilen.james.components.mailet.LogInfo">
>>> <text>Recipient is ExactAndCatchAllRedirections</text>
>>> </mailet>
>>> is not catching it. If I put the header on the message itself,
>> then it
>>> is getting it.
>>> 
>>> Is it a bug in the matcher? Should I use another matcher?
>>> thanks
>>> 
>>> On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com>
>>> wrote:
>>> 
>>>> Great, i will try that.
>>>> Thanks
>>>> 
>>>> Le lun. 4 mars 2019 08:02, Raphael OUAZANA
>>>> <ra...@linagora.com> a écrit :
>>>> 
>>>>> Hi,
>>>>> 
>>>>> Le 2019-03-04 13:16, Simon Levesque a écrit :
>>>>>> Hi all,
>>>>>> 
>>>>>> I created a mailet that modifies some recipients. When
>> modifying
>>>>> them,
>>>>>> I
>>>>>> want to add an header only to those modified.
>>>>>> Given the method's signature:
>>>>>> 
>>>>>> public void service(Mail mail) throws MessagingException {
>>>>>> 
>>>>>> It looks like I can only modify one mail.
>>>>>> 
>>>>>> From the documentation, I recal that if one message has 5
>>>>> recipients,
>>>>>> then
>>>>>> they would be splited in 5 messages (one per recipient) and
>>>>> being
>>>>>> processed
>>>>>> individually, but in pratice, I am not seing that.
>>>>>> Is there a way to do any of these:
>>>>>> 
>>>>>> 1. configure something to have one mail per recipient
>>>>>> 2. from a mailet, split a mail in 2 or call a service to
>>>>> create a
>>>>>> new
>>>>>> mail
>>>>> 
>>>>> Something has been added recently exactly for this purpose:
>>>>> perRecipientHeaders.
>>>>> 
>>>>> See Mail.addSpecificHeaderForRecipient and
>>>>> Mail.getPerRecipientSpecificHeaders.
>>>>> 
>>>>> Regards,
>>>>> Raphaël Ouazana.

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


Re: How to split a message in a mailet

Posted by Simon Levesque <su...@gmail.com>.
Hi Raphael,

I created a matcher and remover that take care of the per recipient headers
as well as the global ones. I copied the existing ones (with their tests)
and added the use cases for per recipient.
They are currently available there:

   -
   https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecific.java
   -
      https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/mailet/RemoveHeaderGlobalAndSpecificTest.java
      -
   https://github.com/foilen/james-extra-components/blob/master/src/main/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecific.java
   -
      https://github.com/foilen/james-extra-components/blob/master/src/test/java/com/foilen/james/components/matcher/HasHeaderGlobalAndSpecificTest.java

I would like to add them in the James project, so I will create a Jira for
them, but I wanted to know what names would you suggest? Mine are pretty
long, so I would like to know your thoughts.

Thanks

On Thu, 7 Mar 2019 at 10:05, Raphael OUAZANA <ra...@linagora.com>
wrote:

> Hi,
>
> You are right HasHeader does not handle perRecipientHeaders.
>
> I'm not sure of the good solution for this: either you can modify
> HasHeader to return a list of recipients depending on
> perRecipientHeaders (a.), or you can write an other matcher (b.).
> Given the documentation I think (b.) would be more appropriate, but
> other advices are very welcome.
>
> Regards,
> Raphaël.
>
> Le 2019-03-06 12:55, Simon Levesque a écrit :
> > Hi,
> > I added that logic to add an header per recipient, but it is being
> > ignored by HasHeader .
> >
> > E.g. in my logs, I can see:
> >
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Recipients]---
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
> > Recipient]---
> > INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com :
> > isRedirection -> true
> >
> > and
> >
> >       <mailet match="HasHeader=isRedirection"
> > class="com.foilen.james.components.mailet.LogInfo">
> >         <text>Recipient is ExactAndCatchAllRedirections</text>
> >       </mailet>
> > is not catching it. If I put the header on the message itself, then it
> > is getting it.
> >
> > Is it a bug in the matcher? Should I use another matcher?
> > thanks
> >
> > On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com>
> > wrote:
> >
> >> Great, i will try that.
> >> Thanks
> >>
> >> Le lun. 4 mars 2019 08:02, Raphael OUAZANA
> >> <ra...@linagora.com> a écrit :
> >>
> >>> Hi,
> >>>
> >>> Le 2019-03-04 13:16, Simon Levesque a écrit :
> >>>> Hi all,
> >>>>
> >>>> I created a mailet that modifies some recipients. When modifying
> >>> them,
> >>>> I
> >>>> want to add an header only to those modified.
> >>>> Given the method's signature:
> >>>>
> >>>> public void service(Mail mail) throws MessagingException {
> >>>>
> >>>> It looks like I can only modify one mail.
> >>>>
> >>>> From the documentation, I recal that if one message has 5
> >>> recipients,
> >>>> then
> >>>> they would be splited in 5 messages (one per recipient) and
> >>> being
> >>>> processed
> >>>> individually, but in pratice, I am not seing that.
> >>>> Is there a way to do any of these:
> >>>>
> >>>> 1. configure something to have one mail per recipient
> >>>> 2. from a mailet, split a mail in 2 or call a service to
> >>> create a
> >>>> new
> >>>> mail
> >>>
> >>> Something has been added recently exactly for this purpose:
> >>> perRecipientHeaders.
> >>>
> >>> See Mail.addSpecificHeaderForRecipient and
> >>> Mail.getPerRecipientSpecificHeaders.
> >>>
> >>> Regards,
> >>> Raphaël Ouazana.
>

Re: How to split a message in a mailet

Posted by Raphael OUAZANA <ra...@linagora.com>.
Hi,

You are right HasHeader does not handle perRecipientHeaders.

I'm not sure of the good solution for this: either you can modify 
HasHeader to return a list of recipients depending on 
perRecipientHeaders (a.), or you can write an other matcher (b.).
Given the documentation I think (b.) would be more appropriate, but 
other advices are very welcome.

Regards,
Raphaël.

Le 2019-03-06 12:55, Simon Levesque a écrit :
> Hi,
> I added that logic to add an header per recipient, but it is being
> ignored by HasHeader .
> 
> E.g. in my logs, I can see:
> 
> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Recipients]---
> INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
> INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
> Recipient]---
> INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com :
> isRedirection -> true
> 
> and
> 
>       <mailet match="HasHeader=isRedirection"
> class="com.foilen.james.components.mailet.LogInfo">
>         <text>Recipient is ExactAndCatchAllRedirections</text>
>       </mailet>
> is not catching it. If I put the header on the message itself, then it
> is getting it.
> 
> Is it a bug in the matcher? Should I use another matcher?
> thanks
> 
> On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com>
> wrote:
> 
>> Great, i will try that.
>> Thanks
>> 
>> Le lun. 4 mars 2019 08:02, Raphael OUAZANA
>> <ra...@linagora.com> a écrit :
>> 
>>> Hi,
>>> 
>>> Le 2019-03-04 13:16, Simon Levesque a écrit :
>>>> Hi all,
>>>> 
>>>> I created a mailet that modifies some recipients. When modifying
>>> them,
>>>> I
>>>> want to add an header only to those modified.
>>>> Given the method's signature:
>>>> 
>>>> public void service(Mail mail) throws MessagingException {
>>>> 
>>>> It looks like I can only modify one mail.
>>>> 
>>>> From the documentation, I recal that if one message has 5
>>> recipients,
>>>> then
>>>> they would be splited in 5 messages (one per recipient) and
>>> being
>>>> processed
>>>> individually, but in pratice, I am not seing that.
>>>> Is there a way to do any of these:
>>>> 
>>>> 1. configure something to have one mail per recipient
>>>> 2. from a mailet, split a mail in 2 or call a service to
>>> create a
>>>> new
>>>> mail
>>> 
>>> Something has been added recently exactly for this purpose:
>>> perRecipientHeaders.
>>> 
>>> See Mail.addSpecificHeaderForRecipient and
>>> Mail.getPerRecipientSpecificHeaders.
>>> 
>>> Regards,
>>> Raphaël Ouazana.

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


Re: How to split a message in a mailet

Posted by Simon Levesque <su...@gmail.com>.
Hi,
I added that logic to add an header per recipient, but it is being ignored
by HasHeader .

E.g. in my logs, I can see:
INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Recipients]---
INFO   | jvm 1    | 2019/03/06 11:44:48 | surivorp@gmail.com
INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com
INFO   | jvm 1    | 2019/03/06 11:44:48 | ---[Mail - Headers Per
Recipient]---
INFO   | jvm 1    | 2019/03/06 11:44:48 | simon@nnnn.com : isRedirection ->
true

and
      <mailet match="HasHeader=isRedirection"
class="com.foilen.james.components.mailet.LogInfo">
        <text>Recipient is ExactAndCatchAllRedirections</text>
      </mailet>
is not catching it. If I put the header on the message itself, then it is
getting it.

Is it a bug in the matcher? Should I use another matcher?
thanks


On Mon, 4 Mar 2019 at 10:06, Simon Levesque <su...@gmail.com> wrote:

> Great, i will try that.
> Thanks
>
> Le lun. 4 mars 2019 08:02, Raphael OUAZANA <ra...@linagora.com>
> a écrit :
>
>> Hi,
>>
>> Le 2019-03-04 13:16, Simon Levesque a écrit :
>> > Hi all,
>> >
>> > I created a mailet that modifies some recipients. When modifying them,
>> > I
>> > want to add an header only to those modified.
>> > Given the method's signature:
>> >
>> > public void service(Mail mail) throws MessagingException {
>> >
>> > It looks like I can only modify one mail.
>> >
>> > From the documentation, I recal that if one message has 5 recipients,
>> > then
>> > they would be splited in 5 messages (one per recipient) and being
>> > processed
>> > individually, but in pratice, I am not seing that.
>> > Is there a way to do any of these:
>> >
>> >    1. configure something to have one mail per recipient
>> >    2. from a mailet, split a mail in 2 or call a service to create a
>> > new
>> >    mail
>>
>> Something has been added recently exactly for this purpose:
>> perRecipientHeaders.
>>
>> See Mail.addSpecificHeaderForRecipient and
>> Mail.getPerRecipientSpecificHeaders.
>>
>> Regards,
>> Raphaël Ouazana.
>>
>

Re: How to split a message in a mailet

Posted by Simon Levesque <su...@gmail.com>.
Great, i will try that.
Thanks

Le lun. 4 mars 2019 08:02, Raphael OUAZANA <ra...@linagora.com> a
écrit :

> Hi,
>
> Le 2019-03-04 13:16, Simon Levesque a écrit :
> > Hi all,
> >
> > I created a mailet that modifies some recipients. When modifying them,
> > I
> > want to add an header only to those modified.
> > Given the method's signature:
> >
> > public void service(Mail mail) throws MessagingException {
> >
> > It looks like I can only modify one mail.
> >
> > From the documentation, I recal that if one message has 5 recipients,
> > then
> > they would be splited in 5 messages (one per recipient) and being
> > processed
> > individually, but in pratice, I am not seing that.
> > Is there a way to do any of these:
> >
> >    1. configure something to have one mail per recipient
> >    2. from a mailet, split a mail in 2 or call a service to create a
> > new
> >    mail
>
> Something has been added recently exactly for this purpose:
> perRecipientHeaders.
>
> See Mail.addSpecificHeaderForRecipient and
> Mail.getPerRecipientSpecificHeaders.
>
> Regards,
> Raphaël Ouazana.
>

Re: How to split a message in a mailet

Posted by Raphael OUAZANA <ra...@linagora.com>.
Hi,

Le 2019-03-04 13:16, Simon Levesque a écrit :
> Hi all,
> 
> I created a mailet that modifies some recipients. When modifying them, 
> I
> want to add an header only to those modified.
> Given the method's signature:
> 
> public void service(Mail mail) throws MessagingException {
> 
> It looks like I can only modify one mail.
> 
> From the documentation, I recal that if one message has 5 recipients, 
> then
> they would be splited in 5 messages (one per recipient) and being 
> processed
> individually, but in pratice, I am not seing that.
> Is there a way to do any of these:
> 
>    1. configure something to have one mail per recipient
>    2. from a mailet, split a mail in 2 or call a service to create a 
> new
>    mail

Something has been added recently exactly for this purpose: 
perRecipientHeaders.

See Mail.addSpecificHeaderForRecipient and 
Mail.getPerRecipientSpecificHeaders.

Regards,
Raphaël Ouazana.

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