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 bt <li...@wapdat.com> on 2003/07/21 18:31:07 UTC

AbstractRedirect.java how to use?

I'm trying to use AbstractRedirect.java to make some custom redirect
behaviour. (different to the default redirection)

I need to use the originalMail.getUserName() to decide who to forward to.

Is it the right approach to over-ride this method in AbstractRedirect?

	protected void setRecipients(
		Mail newMail,
		Collection recipients,
		Mail originalMail)

I looked at the built in Forward mailet, only the no argument setX methods
get over-ridden.  Is it valid to over-ride the setX(mail, collection, mail)
signatures?

Then do
((MailImpl) newMail).setRecipients(forwardedAddresses);
With the new addresses to forward to?

Is there more I need to do to get forwarding working?

I seem to just get in a loop. ie I forward a "A" which then comes back
through the mailet who forwards to "A" (repeat).

What I am trying to achieve is to "forward as a copy", ie send to the
original recipient, and forward also to another address.

Has anyone any tips?  Is using AbstractRedirect the right thing to do?

Regards
Lindsay Smith


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


RE: AbstractRedirect.java how to use?

Posted by Vincenzo Gianferrari Pini <vi...@praxis.it>.
Lindsay,

You should have getRecipients(Mail) return a collection with the new extra recipient, and getPassThrough() return true so that the original message is delivered to the original recipients.

This should be totally enough, unless you want both the original and the new recipients know about each other: in this case build a new consolidated collection in getRecipients(Mail) and return an equivalent InternetAddress[] in getTo(Mail) too, with getPassThrough() returning false. 

Vincenzo

> -----Original Message-----
> From: Lindsay Smith [mailto:lindsay@wapdat.com]
> Sent: lunedì 21 luglio 2003 19.53
> To: James Users List
> Subject: RE: AbstractRedirect.java how to use?
> 
> 
> Hi Vincenzo,
> 
> I think what I want is I need a custom Mailet because I have to query a DB
> to get who the forward addresses are.
> From what you explain I think I want ...
> 
> AbstractRedirect.getRecipients(Mail)
> 
> What additional stuff do I need to do to forward the mail to new extra
> recipients?
> 
> Just:
> mail.setRecipients(Collection);
> 
> Do I need to do anything after this?
> 
> It seems this setRecipients() signature in the Mail interface 
> must have been
> added after 2.2.0a7 because I get unresolved symbol compiling but it's in
> the online javadoc.
> 
> Any advice appreciated.
> 
> Regards
> Lindsay Smith
> 
> -----Original Message-----
> From: Vincenzo Gianferrari Pini
> [mailto:vincenzo.gianferraripini@praxis.it]
> Sent: 21 July 2003 18:04
> To: James Users List
> Subject: RE: AbstractRedirect.java how to use?
> 
> 
> Yes, you can override AbstractRedirect.setRecipients(Mail, Collection,
> Mail), although it would be better to override
> AbstractRedirect.getRecipients() or AbstractRedirect.getRecipients(Mail)
> (none of them are final on purpose).
> 
> The choice is based on the following logic:
> 
> 1) Use AbstractRedirect.getRecipients() if the recipients are a fixed
> address list, and/or one or more of the "magic" addresses (the postmaster
> address or SpecialAddress.SENDER or SpecialAddress.REVERSE_PATH or
> SpecialAddress.RECIPIENTS.
> 
> 2) Use AbstractRedirect.getRecipients(Mail) if the recipients are to be
> determined "dynamically" using information from the original mail.
> 
> 3) Use AbstractRedirect.setRecipients(Mail, Collection, Mail) if 
> you need to
> do something more than sending to the recipients list.
> 
> You may even not need to write any new mailet, and just use either Resend,
> Redirect or Forward with the appropriate parameters.
> 
> If you tell me whom do you want to "forward as a copy" to (which logic you
> want to implement), I can give you an advice.
> 
> Vincenzo
> 
> > -----Original Message-----
> > From: bt [mailto:lindsay@wapdat.com]
> > Sent: lunedì 21 luglio 2003 18.31
> > To: James Users List
> > Subject: AbstractRedirect.java how to use?
> >
> >
> > I'm trying to use AbstractRedirect.java to make some custom redirect
> > behaviour. (different to the default redirection)
> >
> > I need to use the originalMail.getUserName() to decide who to 
> forward to.
> >
> > Is it the right approach to over-ride this method in AbstractRedirect?
> >
> > 	protected void setRecipients(
> > 		Mail newMail,
> > 		Collection recipients,
> > 		Mail originalMail)
> >
> > I looked at the built in Forward mailet, only the no argument 
> setX methods
> > get over-ridden.  Is it valid to over-ride the setX(mail,
> > collection, mail)
> > signatures?
> >
> > Then do
> > ((MailImpl) newMail).setRecipients(forwardedAddresses);
> > With the new addresses to forward to?
> >
> > Is there more I need to do to get forwarding working?
> >
> > I seem to just get in a loop. ie I forward a "A" which then comes back
> > through the mailet who forwards to "A" (repeat).
> >
> > What I am trying to achieve is to "forward as a copy", ie send to the
> > original recipient, and forward also to another address.
> >
> > Has anyone any tips?  Is using AbstractRedirect the right thing to do?
> >
> > Regards
> > Lindsay Smith
> >
> >
> > ---------------------------------------------------------------------
> > 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
> 


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


Re: listserv problem (was RE: processor question)

Posted by Jay Kraly <ja...@perspectivesoftware.com>.
So then the set of non-matching recipients picks up at the next mailet?

That may explain my problem.  I wrote a matcher called "RecipientIsLike" 
which matches any recipient like "list" and sends it to my custom 
listserv.  The listserv then looks at the original recipient and queries 
the database for the list of users.  Which means that I only have one 
mailet that will match the "list" so that I don't have to modify the 
config.xml file everytime my users add a list to the database.  
Technically both recipients in the example "list1@perspectivehost.com, 
list2@perspectivehost.com" should match.  Then the listserv only 
processes the first in the list so it never sees the second listserv 
address. In your example it would work because you have separate and 
distinct mailet/matches for each list. 

So my backup plan of looping through all recipients in my listserv 
mailet is actually a good solution since it will process all matches, 
and any non-matches will continue on through the processor pipe.  
Right?  I was worried about losing the non-matches but it sounds like 
that won't be a problem.

In any case, it doesn't sound like there are any bugs here, just a 
misunderstanding of how things work.

-J


Noel J. Bergman wrote:

>Wait a minute ... Jay, I was wrong ... distracted making dinner ... hold on.
>
>The matcher does it.  The way a matcher works is that it selects the
>recipients that will be processed by the mailet.  Matchers like HostIs are
>just all or nothing, but otherwise, the matcher says which subset of
>recipients will be processed.
>
>So if I have multiple recipients, and use RecipientIs, then only that
>recipient should be passed along to the mailet for processing.
>
>So if I have e-mail sent to "list1@perspectivehost.com,
>list2@perspectivehost.com", what should happen is that the RecipientIs
>matchers should peel off a single recipient for the listserv mailet.  The
>recipient set will get split into two sets: matching and notMatching.  As
>long as neither one is empty, it continues.  So the matching set, containing
>just the current list, should be processed by the listserv.  The message is
>then ghosted.  But the other set still continues with its duplicate of the
>message.
>
>So now that I've had my dinner, if you are not seeing the above behavior,
>then we need to find out why.
>
>Ignore my earlier message.
>
>	--- Noel
>
>
>---------------------------------------------------------------------
>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: listserv problem (was RE: processor question)

Posted by "Noel J. Bergman" <no...@devtech.com>.
Wait a minute ... Jay, I was wrong ... distracted making dinner ... hold on.

The matcher does it.  The way a matcher works is that it selects the
recipients that will be processed by the mailet.  Matchers like HostIs are
just all or nothing, but otherwise, the matcher says which subset of
recipients will be processed.

So if I have multiple recipients, and use RecipientIs, then only that
recipient should be passed along to the mailet for processing.

So if I have e-mail sent to "list1@perspectivehost.com,
list2@perspectivehost.com", what should happen is that the RecipientIs
matchers should peel off a single recipient for the listserv mailet.  The
recipient set will get split into two sets: matching and notMatching.  As
long as neither one is empty, it continues.  So the matching set, containing
just the current list, should be processed by the listserv.  The message is
then ghosted.  But the other set still continues with its duplicate of the
message.

So now that I've had my dinner, if you are not seeing the above behavior,
then we need to find out why.

Ignore my earlier message.

	--- Noel


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


Re: listserv problem (was RE: processor question)

Posted by Jay Kraly <ja...@perspectivesoftware.com>.
OK, I'll add it.

For future reference what is the mechanism in James that would split the 
two if the first wasn't a "list-" match?  I noticed that if I send to 
"somebody@someexternalhost.com,list-xxxxx@mailhost.perspectivesoftware.com" 
something causes the second email address for the listserv to be put 
back through the processors so that it works as expected.  It seems like 
if I could put the listserv mailet at a different point in the processor 
piping the two addresses would be split into independent messages before 
it ever got to the mailet and matcher.

In the meantime I'll probably modify my listserv mailet to loop through 
all the recipients and send to them rather than just the first in the list.

Thanks.

-J

Noel J. Bergman wrote:

>>if somebody sent to "list-xxxxx@mailhost.perspectivehost.com,
>>list-yyyyy@mailhost.perspectivehost.com" wouldn't the first
>>matcher catch the email and then ghost it when done so the
>>second match on "list-yyyyyy" would never happen?
>>    
>>
>
>Please put that in bugzilla.  There isn't a quick fix because the mailet
>doesn't know the address that caused it to be invoked.
>
>JDBCListserv supports a <list_address> element, which tells it the address
>it supports.  That should probably be added to AvalonListserv.
>
>Mark's new list serve has the same bug.
>
>	--- Noel
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
>
>  
>

listserv problem (was RE: processor question)

Posted by "Noel J. Bergman" <no...@devtech.com>.
> if somebody sent to "list-xxxxx@mailhost.perspectivehost.com,
> list-yyyyy@mailhost.perspectivehost.com" wouldn't the first
> matcher catch the email and then ghost it when done so the
> second match on "list-yyyyyy" would never happen?

Please put that in bugzilla.  There isn't a quick fix because the mailet
doesn't know the address that caused it to be invoked.

JDBCListserv supports a <list_address> element, which tells it the address
it supports.  That should probably be added to AvalonListserv.

Mark's new list serve has the same bug.

	--- Noel


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


Re: processor question

Posted by Jay Kraly <ja...@perspectivesoftware.com>.
Its a listserv based on the old listserv, I think I modified the 
JDBCListServ.  I have the mailet in the root processor, matching on 
"RecipientIsLike=list-".

The problem is that if somebody sends a comma separated list of 
recipients my matcher picks it up as one address and the second address 
just gets dropped.  I'm guessing that somewhere along the way the comma 
separated list should have already been broken up into two "rcpt to:' 
entries, but that is out of my control.

In your example below, if somebody sent to 
"list-xxxxx@mailhost.perspectivehost.com,list-yyyyy@mailhost.perspectivehost.com" 
wouldn't the first matcher catch the email and then ghost it when done 
so the second match on "list-yyyyyy" would never happen?

-J

Noel Bergman wrote:

>>if somebody sends to "list-xxxxxxx@mailhost.perspectivesoftware.com,
>>list-yyyyyyy@mailhost.perspectivesoftware.com" the mailet only picks
>>up the first list and discards the second address.
>>    
>>
>
>How are you matching?  Which mailet?  I would have something like:
>
>  <mailet match="CommandForListserv=list-xxxxx@mailhost.perspectivehost.com"
>          class="AvalonListservManager">
>    <repositoryName>list-xxxxx</repositoryName>
>  </mailet>
>
>  <mailet match="CommandForListserv=list-yyyyy@mailhost.perspectivehost.com"
>          class="AvalonListservManager">
>    <repositoryName>list-yyyyy</repositoryName>
>  </mailet>
>
>  <mailet match="RecipientIs=list-xxxxx@mailhost.perspectivehost.com"
>          class="AvalonListserv">
>    <repositoryName>list-xxxxx</repositoryName>
>  </mailet>
>
>  <mailet match="RecipientIs=list-yyyyy@mailhost.perspectivehost.com"
>          class="AvalonListserv">
>    <repositoryName>list-yyyyy</repositoryName>
>  </mailet>
>
>That's using the old listserv (current listserv).  I haven't switched over
>to using Mark's new one, yet.
>
>	--- Noel
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
>
>  
>

RE: processor question

Posted by "Noel J. Bergman" <no...@devtech.com>.
> if somebody sends to "list-xxxxxxx@mailhost.perspectivesoftware.com,
> list-yyyyyyy@mailhost.perspectivesoftware.com" the mailet only picks
> up the first list and discards the second address.

How are you matching?  Which mailet?  I would have something like:

  <mailet match="CommandForListserv=list-xxxxx@mailhost.perspectivehost.com"
          class="AvalonListservManager">
    <repositoryName>list-xxxxx</repositoryName>
  </mailet>

  <mailet match="CommandForListserv=list-yyyyy@mailhost.perspectivehost.com"
          class="AvalonListservManager">
    <repositoryName>list-yyyyy</repositoryName>
  </mailet>

  <mailet match="RecipientIs=list-xxxxx@mailhost.perspectivehost.com"
          class="AvalonListserv">
    <repositoryName>list-xxxxx</repositoryName>
  </mailet>

  <mailet match="RecipientIs=list-yyyyy@mailhost.perspectivehost.com"
          class="AvalonListserv">
    <repositoryName>list-yyyyy</repositoryName>
  </mailet>

That's using the old listserv (current listserv).  I haven't switched over
to using Mark's new one, yet.

	--- Noel


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


processor question

Posted by Jay Kraly <ja...@perspectivesoftware.com>.
I'm using James to serve a couple lists using a slightly modified 
version of the listserv provided in the James source.  Everything works 
fine if somebody emails "list-xxxxxx@mailhost.perspectivesoftware.com".  
I have a matcher in the root processor that catches "list-xxxxxxx" and 
sends it to the listserv mailet.  However, if somebody sends to 
"list-xxxxxxx@mailhost.perspectivesoftware.com,list-yyyyyyy@mailhost.perspectivesoftware.com" 
the mailet only picks up the first list and discards the second address.

Is there a better processor for me to put the matcher where it would 
catch the two distinct lists after they are split by James?  Or do I 
have to rewrite the listserv to be more intelligent about recognizing 
that more than one list is involved?

Thanks

-J










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


RE: AbstractRedirect.java how to use?

Posted by "Noel J. Bergman" <no...@devtech.com>.
> I think what I want is I need a custom Mailet because I have to query a DB
> to get who the forward addresses are.

Yes, that is one of the original intents fro the Redirect hierarchy.

> AbstractRedirect.getRecipients(Mail)

Whatever you return will be used as the new recipient list.  You can either
populate it completely, or just the new recipients (and use passthrough for
the old ones, as Vincenzo mentioned).  Depends upon your application.

	--- Noel


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


RE: AbstractRedirect.java how to use?

Posted by Lindsay Smith <li...@wapdat.com>.
Hi Vincenzo,

I think what I want is I need a custom Mailet because I have to query a DB
to get who the forward addresses are.
>From what you explain I think I want ...

AbstractRedirect.getRecipients(Mail)

What additional stuff do I need to do to forward the mail to new extra
recipients?

Just:
mail.setRecipients(Collection);

Do I need to do anything after this?

It seems this setRecipients() signature in the Mail interface must have been
added after 2.2.0a7 because I get unresolved symbol compiling but it's in
the online javadoc.

Any advice appreciated.

Regards
Lindsay Smith

-----Original Message-----
From: Vincenzo Gianferrari Pini
[mailto:vincenzo.gianferraripini@praxis.it]
Sent: 21 July 2003 18:04
To: James Users List
Subject: RE: AbstractRedirect.java how to use?


Yes, you can override AbstractRedirect.setRecipients(Mail, Collection,
Mail), although it would be better to override
AbstractRedirect.getRecipients() or AbstractRedirect.getRecipients(Mail)
(none of them are final on purpose).

The choice is based on the following logic:

1) Use AbstractRedirect.getRecipients() if the recipients are a fixed
address list, and/or one or more of the "magic" addresses (the postmaster
address or SpecialAddress.SENDER or SpecialAddress.REVERSE_PATH or
SpecialAddress.RECIPIENTS.

2) Use AbstractRedirect.getRecipients(Mail) if the recipients are to be
determined "dynamically" using information from the original mail.

3) Use AbstractRedirect.setRecipients(Mail, Collection, Mail) if you need to
do something more than sending to the recipients list.

You may even not need to write any new mailet, and just use either Resend,
Redirect or Forward with the appropriate parameters.

If you tell me whom do you want to "forward as a copy" to (which logic you
want to implement), I can give you an advice.

Vincenzo

> -----Original Message-----
> From: bt [mailto:lindsay@wapdat.com]
> Sent: lunedì 21 luglio 2003 18.31
> To: James Users List
> Subject: AbstractRedirect.java how to use?
>
>
> I'm trying to use AbstractRedirect.java to make some custom redirect
> behaviour. (different to the default redirection)
>
> I need to use the originalMail.getUserName() to decide who to forward to.
>
> Is it the right approach to over-ride this method in AbstractRedirect?
>
> 	protected void setRecipients(
> 		Mail newMail,
> 		Collection recipients,
> 		Mail originalMail)
>
> I looked at the built in Forward mailet, only the no argument setX methods
> get over-ridden.  Is it valid to over-ride the setX(mail,
> collection, mail)
> signatures?
>
> Then do
> ((MailImpl) newMail).setRecipients(forwardedAddresses);
> With the new addresses to forward to?
>
> Is there more I need to do to get forwarding working?
>
> I seem to just get in a loop. ie I forward a "A" which then comes back
> through the mailet who forwards to "A" (repeat).
>
> What I am trying to achieve is to "forward as a copy", ie send to the
> original recipient, and forward also to another address.
>
> Has anyone any tips?  Is using AbstractRedirect the right thing to do?
>
> Regards
> Lindsay Smith
>
>
> ---------------------------------------------------------------------
> 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: AbstractRedirect.java how to use?

Posted by Vincenzo Gianferrari Pini <vi...@praxis.it>.
Yes, you can override AbstractRedirect.setRecipients(Mail, Collection, Mail), although it would be better to override AbstractRedirect.getRecipients() or AbstractRedirect.getRecipients(Mail) (none of them are final on purpose).

The choice is based on the following logic:

1) Use AbstractRedirect.getRecipients() if the recipients are a fixed address list, and/or one or more of the "magic" addresses (the postmaster address or SpecialAddress.SENDER or SpecialAddress.REVERSE_PATH or SpecialAddress.RECIPIENTS.

2) Use AbstractRedirect.getRecipients(Mail) if the recipients are to be determined "dynamically" using information from the original mail.

3) Use AbstractRedirect.setRecipients(Mail, Collection, Mail) if you need to do something more than sending to the recipients list.

You may even not need to write any new mailet, and just use either Resend, Redirect or Forward with the appropriate parameters.

If you tell me whom do you want to "forward as a copy" to (which logic you want to implement), I can give you an advice.

Vincenzo

> -----Original Message-----
> From: bt [mailto:lindsay@wapdat.com]
> Sent: lunedì 21 luglio 2003 18.31
> To: James Users List
> Subject: AbstractRedirect.java how to use?
> 
> 
> I'm trying to use AbstractRedirect.java to make some custom redirect
> behaviour. (different to the default redirection)
> 
> I need to use the originalMail.getUserName() to decide who to forward to.
> 
> Is it the right approach to over-ride this method in AbstractRedirect?
> 
> 	protected void setRecipients(
> 		Mail newMail,
> 		Collection recipients,
> 		Mail originalMail)
> 
> I looked at the built in Forward mailet, only the no argument setX methods
> get over-ridden.  Is it valid to over-ride the setX(mail, 
> collection, mail)
> signatures?
> 
> Then do
> ((MailImpl) newMail).setRecipients(forwardedAddresses);
> With the new addresses to forward to?
> 
> Is there more I need to do to get forwarding working?
> 
> I seem to just get in a loop. ie I forward a "A" which then comes back
> through the mailet who forwards to "A" (repeat).
> 
> What I am trying to achieve is to "forward as a copy", ie send to the
> original recipient, and forward also to another address.
> 
> Has anyone any tips?  Is using AbstractRedirect the right thing to do?
> 
> Regards
> Lindsay Smith
> 
> 
> ---------------------------------------------------------------------
> 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