Hi Tim,

SenderIsLocal is typically used in combination with ToSenderFolder.

In that case, we need to store only once the mail in the Sent Folder, but the current mailet architecture is designed/focused on recipients, not senders.

Matcher/Mailets will be invoked numerous times for a single mail (for all the local recipients, and once for the remote one).

So we endup with multiple copies of the mail in the Sent Folder.

I need to think about it. Any other thoughts welcome :)

Thx, Eric

On 07/18/2012 02:29 AM, timprepscius wrote:
ok

so if I change the return to be getRecipients
then things work properly:

  svn diff
Index: src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java
===================================================================
--- src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java        
(revision 1362688)
+++ src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java        
(working copy)
@@ -27,12 +27,21 @@
  import org.apache.mailet.MailAddress;
  import org.apache.mailet.base.GenericMatcher;

+import java.util.ArrayList;
+import java.util.List;
+
  /**
   * Matches mail where the sender is local.
   */
  public class SenderIsLocal extends GenericMatcher {

      public final Collection<MailAddress> match(Mail mail) throws 
MessagingException {
-        return (getMailetContext().isLocalEmail(mail.getSender())) ? 
Arrays.asList(mail.getSender()): null;
+
+       if (mail.getSender() != null && 
getMailetContext().isLocalEmail(mail.getSender()))
+       {
+               return mail.getRecipients();
+       }
+
+       return null;
      }
  }


On Jul 17, 2012, at 8:10 PM, timprepscius wrote:

ok testing is showing that this fixes the exception, however.

now james is thinking that I am send mails to myself.
and I receive (in box) mails I send.

I can only surmise this is a function of the new "recipient" being returned by 
the to sender.

I'll try not to use "getSender()" see what happens

-tim

On Jul 17, 2012, at 7:59 PM, timprepscius wrote:

testing now

On Jul 17, 2012, at 7:58 PM, timprepscius wrote:

possibly this fix:

svn diff
Index: src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java
===================================================================
--- src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java        
(revision 1362688)
+++ src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java        
(working copy)
@@ -27,12 +27,23 @@
import org.apache.mailet.MailAddress;
import org.apache.mailet.base.GenericMatcher;

+import java.util.ArrayList;
+import java.util.List;
+
/**
* Matches mail where the sender is local.
*/
public class SenderIsLocal extends GenericMatcher {

   public final Collection<MailAddress> match(Mail mail) throws 
MessagingException {
-        return (getMailetContext().isLocalEmail(mail.getSender())) ? 
Arrays.asList(mail.getSender()): null;
+
+       if (mail.getSender() != null && 
getMailetContext().isLocalEmail(mail.getSender()))
+       {
+               List<MailAddress> recipients = new ArrayList<MailAddress>();
+               recipients.add(mail.getSender());
+               return recipients;
+       }
+
+       return null;
   }
}


On Jul 17, 2012, at 7:52 PM, timprepscius wrote:

ok, I have a feeling that

the Arras.asList is the culprit of these errors.

the reason being that array I believe is being incorporated into some mail 
structure and then manipulated.
which is impossible.

-tim

On Jul 17, 2012, at 7:29 PM, timprepscius wrote:

so,

I need to get this change in:

svn diff
Index: src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java
===================================================================
--- src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java        
(revision 1362688)
+++ src/main/java/org/apache/james/transport/matchers/SenderIsLocal.java        
(working copy)
@@ -33,6 +33,9 @@
public class SenderIsLocal extends GenericMatcher {

public final Collection<MailAddress> match(Mail mail) throws MessagingException 
{
+       if (mail.getSender() == null)
+               return null;
+
     return (getMailetContext().isLocalEmail(mail.getSender())) ? 
Arrays.asList(mail.getSender()): null;
}
}



so I used trunk of mailet:

svn info
Path: .
URL: http://svn.apache.org/repos/asf/james/mailet/standard/trunk
Repository Root: http://svn.apache.org/repos/asf
Repository UUID: 13f79535-47bb-0310-9956-ffa450edef68
Revision: 1362688
Node Kind: directory
Schedule: normal
Last Changed Author: eric
Last Changed Rev: 1362051
Last Changed Date: 2012-07-16 10:19:21 -0400 (Mon, 16 Jul 2012)


I built it and deployed it into the lib directory:
james@blue:~/apache-james/lib$ ls -la *standard*
lrwxrwxrwx 1 james james     60 Jul 17 19:20 
apache-standard-mailets-1.2-20120709.004650-715.jar -> 
apache-standard-mailets-1.2-20120709.004650-715.jar.original
-rw------- 1 james james 121046 Jul 10 08:39 
apache-standard-mailets-1.2-20120709.004650-715.jar.original
-rw-r--r-- 1 james james 120541 Jul 17 18:33 
apache-standard-mailets-1.2-SNAPSHOT.jar


---

and now james has lots of new errors.
actually I can't send any mail without a bounce being triggered.


INFO  19:15:20,910 | james.mailetcontext | Local delivery with ToSenderFolder 
mailet for mail Mail1342566918279-811ba289-672b-4a55-a2fd-e03499aec883-!383287 
with sender …..
INFO  19:15:20,938 | james.mailetcontext | Error while storing mail.
java.lang.UnsupportedOperationException
    at java.util.AbstractList.remove(Unknown Source)
    at java.util.AbstractList$Itr.remove(Unknown Source)
    at 
org.apache.james.transport.mailets.AbstractRecipientRewriteTableMailet.service(AbstractRecipientRewriteTableMailet.java:78)
    at 
org.apache.james.transport.mailets.LocalDelivery.service(LocalDelivery.java:70)
    at 
org.apache.james.mailetcontainer.impl.camel.CamelProcessor.process(CamelProcessor.java:65)



I'm going to go to the previous tag, fix isSenderLocal there.

thought you would like to know, to possibly review changes which have happened 
between the 10th and the 17th.


-tim

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]






---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



--
eric | http://about.echarles.net | @echarles


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to