Well, seems it doesn't work in the real world.

The way I mentioned worked in a VM so far - but after I upgraded my root-server and did the same I know get this issue:

INFO   | jvm 1    | 2019/05/26 20:58:02 | INFO  20:58:02,242 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection established from 127.0.0.1 INFO   | jvm 1    | 2019/05/26 20:58:02 | INFO  20:58:02,300 | org.apache.james.domainlist.lib.AbstractDomainList | Local host is: 127.0.0.1 INFO   | jvm 1    | 2019/05/26 20:58:02 | INFO  20:58:02,423 | org.apache.james.smtpserver.SendMailHandler | Successfully spooled mail Mail1558897082344-b3644bc7-10c4-46a7-b670-75cf4dc9fd94 from MaybeSender{mailAddress=Optional[cryptea...@root1.cryptearth.de]} on localhost/127.0.0.1 for [cryptea...@root1.cryptearth.de] INFO   | jvm 1    | 2019/05/26 20:58:02 | INFO  20:58:02,507 | org.apache.james.protocols.netty.BasicChannelUpstreamHandler | Connection closed for 127.0.0.1 INFO   | jvm 1    | 2019/05/26 20:58:03 | ERROR 20:58:03,024 | org.apache.james.mailetcontainer.impl.camel.CamelProcessor | Exception calling Redirect: Unable to create a new message name: too long. Possible loop in config.xml. INFO   | jvm 1    | 2019/05/26 20:58:03 | javax.mail.MessagingException: Unable to create a new message name: too long. Possible loop in config.xml. INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.server.core.MailImpl.detectPossibleLoop(MailImpl.java:344) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.server.core.MailImpl.deriveNewName(MailImpl.java:321) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.server.core.MailImpl.duplicate(MailImpl.java:103) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.transport.mailets.redirect.ProcessRedirectNotify.process(ProcessRedirectNotify.java:49) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.transport.mailets.Redirect.service(Redirect.java:475) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.mailetcontainer.impl.camel.CamelProcessor.process(CamelProcessor.java:81) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor$MailetContainerRouteBuilder.handleMailet(CamelMailetProcessor.java:178) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor$MailetContainerRouteBuilder.lambda$configure$0(CamelMailetProcessor.java:155) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:715) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:638) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:248) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.Splitter.process(Splitter.java:130) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.component.direct.DirectBlockingProducer.process(DirectBlockingProducer.java:53) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:186) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.processor.SharedCamelInternalProcessor.process(SharedCamelInternalProcessor.java:86) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:541) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:506) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:369) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:506) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:229) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:144) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:161) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:168) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor.service(CamelMailetProcessor.java:68) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.mailetcontainer.lib.AbstractStateCompositeProcessor.service(AbstractStateCompositeProcessor.java:84) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at org.apache.james.mailetcontainer.impl.JamesMailSpooler.lambda$run$0(JamesMailSpooler.java:163) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) INFO   | jvm 1    | 2019/05/26 20:58:03 |       at java.lang.Thread.run(Thread.java:748)
INFO   | jvm 1    | 2019/05/26 20:58:03 |
INFO   | jvm 1    | 2019/05/26 20:58:03 | INFO  20:58:03,025 | org.apache.james.transport.mailets.ToRepository | Storing mail fd94-!5647419-!8598886-!8671760-!8516799-!7948334-!6362370-!1064056-!8846222 in MailRepositoryUrl{value=file://var/mail/error/}

This is the content of the filtered message:

cryptearth@localhost:~/james-server-app-3.3.0/var/mail/error> cat 666439342D21353634373431392D21383539383838362D21383637313736302D21383531363739392D21373934383333342D21363336323337302D21313036343035362D2138383436323232.Repository.FileStreamStore
To: local-serv...@cryptearth.de
Message-ID: <201905261858.x4qiw2wp003...@root1.cryptearth.de>
MIME-Version: 1.0
Received: from localhost (EHLO root1.cryptearth.de) ([127.0.0.1])
          by localhost (JAMES SMTP Server ) with ESMTP ID -1238704049
          for <cryptea...@root1.cryptearth.de>;
          Sun, 26 May 2019 20:58:02 +0200 (CEST)
Received: (from cryptearth@localhost)
        by root1.cryptearth.de (8.15.2/8.15.2/Submit) id x4QIw2wp003888;
        Sun, 26 May 2019 20:58:02 +0200
Date: Sun, 26 May 2019 20:58:02 +0200
From: "(Cron Daemon)" <cryptea...@root1.cryptearth.de>
Subject: Cron <cryptearth@root1> /home/cryptearth/bin/test.sh
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=4>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/1000>
X-Cron-Env: <DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus>
X-Cron-Env: <LANG=de_DE.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/cryptearth>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=cryptearth>
X-Cron-Env: <USER=cryptearth>

test
cryptearth@localhost:~/james-server-app-3.3.0/var/mail/error>

So, the redirect seems to work as far to change the recipient, but then it can't be sent to the local user account. I'm unsure if it's maybe some DNS/IP error as the way I re-installed the system isn't supported by OVH. So maybe I made an error somewhere. What's bothering me that the hostname sometimes keep change back to localhost although it's correctly set anywhere.

Maybe I get in touch with OVH support

Matt

Am 24.05.2019 um 01:58 schrieb cryptearth:
Hey there, Matt here again.

Long time since my last update on this topic, but now I got a pretty easy solution.

On May 22nd OpenSUSE 15.1 was released, and with this new update I again looked at my "problem" about how to deal with apache and other local mail. Instead of my initial thoughts I hadn't to implement any myself, but james also comes with anything needed. The two keywords here are the CompositeMatcher and the Redirect mailet.

To recap: basically I want to filter any local mail to a special service user except those from authed smtp and apache (wich is set to webmas...@cryptearth.de in php.ini).

CompositeMatcher offers a way to easy implement this filter rule:

<matcher name="local-service" match="org.apache.james.mailetcontainer.impl.matchers.And">
    <matcher match="RemoteAddrInNetwork=127.0.0.0/8" />
    <matcher match="org.apache.james.mailetcontainer.impl.matchers.Not">
        <matcher match="SMTPAuthSuccessful" />
    </matcher>
    <matcher match="org.apache.james.mailetcontainer.impl.matchers.Not">
        <matcher match="SenderIs=webmas...@cryptearth.de" />
    </matcher>
</matcher>

I guess this speaks for itself, at least I guess anyone subscribed to this mailing-list should understand what this basic logic does. One side-note: on start up the code that creates the config only looks for Matchers and Mailets in org.apache.james.transport.matchers.* - so any other classes has to be referenced by its FQN.

As I now have all those mails I want to filter into the special mailbox an easy Redirect does the trick about rewriting the recipient:

<mailet match="local-service" class="Redirect">
    <to>local-serv...@cryptearth.de</to>
</mailet>

The very convenient thing for apache is that every outgoing mail is also saved automatic in SENT as for any existing local user.

I only came up with this as I started to dig my way around the github and wasn't satisfied with this compilcated way of looking up the API. So I quickly asked google about creating a complete javadoc - mvn javadoc:aggregate-jar did it. So I got an easy browsable api-doc. About placement I inserted it right at top of root processor, even above the postmaster mailet. As it works it can't be that wrong, but if there is a better spot than right at top please tell me.

So, this concludes my question about how to combine james with sendmail in a way sendmail is only the dumb nullclient forwarding all local generated mail to james. As the Redirect mailet also offers other rewrites of the headers I guess it could be used to do a bit more with a bit more work on the configs.

Thanks for anyone helped about this topic - a huge help was the last reply from Benoit about using the RemoteAddrInNetwork class.


So long,

Matt
<truncated>

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

Reply via email to