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 Aleksey Medvedev <am...@mail.ru> on 2009/12/23 14:33:55 UTC

Matcher "HasMailAttribute" skips messages with "org.apache.james.fetchmail.isUserUndefined" attribute

Hello.

I use James server 2.3.2 with fetchmail component enabled. I need to resend all messages from 
fetchmail that have a recipient not defined in James, to postmaster.
So I try to use "org.apache.james.fetchmail.isUserUndefined" attribute. I've added a simple test 
mailet to the top of "transport" processor to verify, if this attribute is pocessed correctly.

Here it is:
  <mailet match="HasMailAttribute=org.org.apache.james.fetchmail.isUserUndefined" class="LogMessage">
     <passThrough>false</passThrough>
     <comment>isUserUndefined found!</comment>
  </mailet>

So I expect, that the message should be logged to mailet.log and its processing should stop. But in 
fact nothing appears in log and the message ends its life in "address-error" repository, put there 
by local-address-error processor. So I suspect, that "HasMailAttribute" matcher does not see this 
"org.apache.james.fetchmail.isUserUndefined" attribute, my mailet is not invoked and the message 
continues its way through transport processor.

By the way, if I change attribute in my mailet, for example to "HasMailAttribute= 
org.apache.james.fetchmail.taskName", then all messages from fetchmail are actually processed by it. 
So my problem is with "...isUserUndefined" attribute.

Please shom me my mistake and sorry for my english :)



Thank you.


Aleksey

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


Re: Matcher "HasMailAttribute" skips messages with "org.apache.james.fetchmail.isUserUndefined" attribute

Posted by Norman Maurer <no...@googlemail.com>.
Sounds like a bug to me.. Please open a jira issue for it .

https://issues.apache.org/jira/browse/JAMES

Thx,
Norman


2009/12/25 Aleksey Medvedev <am...@mail.ru>:
> I've found the answer myself. The matter is that fetchmail's message
> processor adds attributes with "null" value like that
> (src/java/org/apache/james/fetchmail/MessageProcessor.java):
>
>        if (isUserUndefined())
>            aMail.setAttribute(getAttributePrefix() + "isUserUndefined",
> null);
>
>
> But HasMailAttrbute matcher ignores attributes with "null" value
> (src/java/org/apache/james/transport/matchers/HasMailAttribute.java):
>
>        if (mail.getAttribute (attributeName) != null) {
>            return mail.getRecipients();
>        }
>
>
> So all I had to do is to change null assignments to all attributes in
> MessageProcessor.java to something like this:
>        if (isUserUndefined())
>            aMail.setAttribute(getAttributePrefix() + "isUserUndefined",
> "true");
> and to rebuild James. Now everything works just as expected.
>
>
> By the way, MessageProcessor.java is the only place where mail attributes
> are initialized with nulls. Considering the fact, that such attributes will
> surely be ignored by HasMailAttribute and HasMailAttributeWithValue
> matchers, it definitely looks like a code shortcoming (don't want to say
> bug). Hope that this info may prove useful to developers.
>
>
> Aleksey.
>
>
>> Hello.
>>
>> I use James server 2.3.2 with fetchmail component enabled. I need to
>> resend all messages from fetchmail that have a recipient not defined in
>> James, to postmaster.
>> So I try to use "org.apache.james.fetchmail.isUserUndefined" attribute.
>> I've added a simple test mailet to the top of "transport" processor to
>> verify, if this attribute is pocessed correctly.
>>
>> Here it is:
>>  <mailet
>> match="HasMailAttribute=org.org.apache.james.fetchmail.isUserUndefined"
>> class="LogMessage">
>>    <passThrough>false</passThrough>
>>    <comment>isUserUndefined found!</comment>
>>  </mailet>
>>
>> So I expect, that the message should be logged to mailet.log and its
>> processing should stop. But in fact nothing appears in log and the message
>> ends its life in "address-error" repository, put there by
>> local-address-error processor. So I suspect, that "HasMailAttribute" matcher
>> does not see this "org.apache.james.fetchmail.isUserUndefined" attribute, my
>> mailet is not invoked and the message continues its way through transport
>> processor.
>>
>> By the way, if I change attribute in my mailet, for example to
>> "HasMailAttribute= org.apache.james.fetchmail.taskName", then all messages
>> from fetchmail are actually processed by it. So my problem is with
>> "...isUserUndefined" attribute.
>>
>> Please shom me my mistake and sorry for my english :)
>>
>>
>>
>> Thank you.
>>
>>
>> Aleksey
>>
>> ---------------------------------------------------------------------
>> 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: Matcher "HasMailAttribute" skips messages with "org.apache.james.fetchmail.isUserUndefined" attribute

Posted by Aleksey Medvedev <am...@mail.ru>.
I've found the answer myself. The matter is that fetchmail's message processor adds attributes with 
"null" value like that (src/java/org/apache/james/fetchmail/MessageProcessor.java):

         if (isUserUndefined())
             aMail.setAttribute(getAttributePrefix() + "isUserUndefined", null);


But HasMailAttrbute matcher ignores attributes with "null" value 
(src/java/org/apache/james/transport/matchers/HasMailAttribute.java):

         if (mail.getAttribute (attributeName) != null) {
             return mail.getRecipients();
         }


So all I had to do is to change null assignments to all attributes in MessageProcessor.java to 
something like this:
         if (isUserUndefined())
             aMail.setAttribute(getAttributePrefix() + "isUserUndefined", "true");
and to rebuild James. Now everything works just as expected.


By the way, MessageProcessor.java is the only place where mail attributes are initialized with 
nulls. Considering the fact, that such attributes will surely be ignored by HasMailAttribute and 
HasMailAttributeWithValue matchers, it definitely looks like a code shortcoming (don't want to say 
bug). Hope that this info may prove useful to developers.


Aleksey.


> Hello.
> 
> I use James server 2.3.2 with fetchmail component enabled. I need to 
> resend all messages from fetchmail that have a recipient not defined in 
> James, to postmaster.
> So I try to use "org.apache.james.fetchmail.isUserUndefined" attribute. 
> I've added a simple test mailet to the top of "transport" processor to 
> verify, if this attribute is pocessed correctly.
> 
> Here it is:
>  <mailet 
> match="HasMailAttribute=org.org.apache.james.fetchmail.isUserUndefined" 
> class="LogMessage">
>     <passThrough>false</passThrough>
>     <comment>isUserUndefined found!</comment>
>  </mailet>
> 
> So I expect, that the message should be logged to mailet.log and its 
> processing should stop. But in fact nothing appears in log and the 
> message ends its life in "address-error" repository, put there by 
> local-address-error processor. So I suspect, that "HasMailAttribute" 
> matcher does not see this "org.apache.james.fetchmail.isUserUndefined" 
> attribute, my mailet is not invoked and the message continues its way 
> through transport processor.
> 
> By the way, if I change attribute in my mailet, for example to 
> "HasMailAttribute= org.apache.james.fetchmail.taskName", then all 
> messages from fetchmail are actually processed by it. So my problem is 
> with "...isUserUndefined" attribute.
> 
> Please shom me my mistake and sorry for my english :)
> 
> 
> 
> Thank you.
> 
> 
> Aleksey
> 
> ---------------------------------------------------------------------
> 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: Matcher "HasMailAttribute" skips messages with "org.apache.james.fetchmail.isUserUndefined" attribute

Posted by Aleksey Medvedev <am...@mail.ru>.
Typo is in the message, here is the exact config

<mailet match="HasMailAttribute=org.apache.james.fetchmail.isUserUndefined" class="LogMessage">
    <passThrough>false</passThrough>
    <comment>isUserUndefined found!</comment>
</mailet>



Aleksey

> 
> You have to "org." in the attribute name... is it a typo in ml message
> or a typo in your config?
> 
> Stefano
> 


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


Re: Matcher "HasMailAttribute" skips messages with "org.apache.james.fetchmail.isUserUndefined" attribute

Posted by Stefano Bagnara <ap...@bago.org>.
2009/12/23 Aleksey Medvedev <am...@mail.ru>:
> Hello.
>
> I use James server 2.3.2 with fetchmail component enabled. I need to resend
> all messages from fetchmail that have a recipient not defined in James, to
> postmaster.
> So I try to use "org.apache.james.fetchmail.isUserUndefined" attribute. I've
> added a simple test mailet to the top of "transport" processor to verify, if
> this attribute is pocessed correctly.
>
> Here it is:
>  <mailet
> match="HasMailAttribute=org.org.apache.james.fetchmail.isUserUndefined"
> class="LogMessage">

You have to "org." in the attribute name... is it a typo in ml message
or a typo in your config?

Stefano

>    <passThrough>false</passThrough>
>    <comment>isUserUndefined found!</comment>
>  </mailet>
>
> So I expect, that the message should be logged to mailet.log and its
> processing should stop. But in fact nothing appears in log and the message
> ends its life in "address-error" repository, put there by
> local-address-error processor. So I suspect, that "HasMailAttribute" matcher
> does not see this "org.apache.james.fetchmail.isUserUndefined" attribute, my
> mailet is not invoked and the message continues its way through transport
> processor.
>
> By the way, if I change attribute in my mailet, for example to
> "HasMailAttribute= org.apache.james.fetchmail.taskName", then all messages
> from fetchmail are actually processed by it. So my problem is with
> "...isUserUndefined" attribute.
>
> Please shom me my mistake and sorry for my english :)
>
>
>
> Thank you.
>
>
> Aleksey
>
> ---------------------------------------------------------------------
> 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