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: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]