Hey there, Matt here again.

So, I think a found a possible solution without any source-file mods but only clever mailet-config in mailetcontainer.xml.

As I dug through the source I found the standard mailets for RecipientIsLocal. Then I found RecipientIsRegex (I might need some help here). Also there is something called RewriteTable.

I set up a fresh opensuse leap 15 - cron sends mails as <user>@<hostname>.<domain> - so I set up a small test-script and looked at log while running james in console mode: when the domainlist doesn't contain <hostname>.<domain> but only <domain> james thinks that <hostname>.<domain> is external and tries RemoteDelivery. So I added <hostname>.<domain> to domainlist. As I just had the domain, but not the user, the mail is denied as user doesn't exists for the domain. When I add the user as <localuser>@<hostname>.<domain> it gets local delivered without additional copy in sent folder. So as I don't want to set up a user for each localuser, but also want to avoid fastfail I come up with: What if I could early check for <whatever>@<hostname>.<domain> and could just re-write it to an existing account in form of <user>@<domain>? When recipient is re-written before RecipientIsLocal is checked, then this should trigger and just deliver any local mail from what ever service to the mailbox I want to.

So I search through the source tree - but couldn't find anything to alter the recipient by mailet. All I found was the recipientrewritetable.xml file and the AddRegexMapping command available in james-cli.sh. The xml-config doesn't seem to help, but the AddRegexMapping command looks good, but I don't understand the command parameters:

AddRegexMapping <user> <domain> <regex>

Can someone get me some hint how to use this command? Or where/how I can setup the recipient-rewrite before RecipientIsLocal is checked?

Thanks in advance,

Matt

Am 27.01.2019 um 15:20 schrieb cryptearth:
So, as far as I dug through the code, it seems to come down to MailetContext.isLocalEmail(MailAddress) wich is checked by RecipientIsLocal (wich I guess also involve somehow a check of isLocalServer(Domain). In transport-processor there is the line

<mailet match="RecipientIsLocal" class="LocalDelivery" />

I looked into LocalDelivery.java, but I guess when this matches it's to late to perform the test I want to about where the mail comes from and where it should send. JamesMailetContext looks good, as it contains isLocalServer(Domain), wich should also used to check SenderIsLocal (wich shouldn't matter, as this test is performed by source 127.0.0.1). As far as I yet could identify, it all comes down to somehow tell the config, that whatever domain sendmail uses (it's either hostname or hostname.domain) is considered as localServer. The wild-card alias shouldn't be any harder to find or figure out as I simply have to rewrite anything that comes from local and is for local, but isn't in localUserList, is re-written to whatever address I want.

I'll report back when I found the lines to alter.

Matt

Am 26.01.2019 um 22:57 schrieb cryptearth:
Currently I'm just using out-of-the-box after clean build. I'll have a look at the mentioned class and the mailetcontainer. Maybe I'll find my way around. Good James is written in Java - the one language I really know.

Thanks for the point in a possible direction. I'll report back when I got something usefull.

Matt

---- Garry Hurley schrieb ----

Matt, are you using a custom mailet, or working out of the box? Take a look at the source for LocalDelivery.java <http://LocalDelivery.java>, and the configuration for local mail in your mailetcontainer.xml <http://mailetcontainer.xml> file. You may have to override some functionality to get the processing you want.

Sent from my iPhone

> On Jan 26, 2019, at 9:36 AM, cryptearth <cryptea...@cryptearth.de <mailto:cryptea...@cryptearth.de>> wrote:
>
> Hey there, Matt here.
>
> So I got sendmail working with james now (tried postfix, but it always complains forwarding to localhost isn't supported as there is no option to ignore false loopback detection), and when used from apache with additional -f parameter all works good. But as there're other services might drop mail into local queue (crontab specificly) I noticed, that I'm still missing something. My goal is somesort of wildcard alias so that no matter from wich user sendmail gets a message, except the one I use for apache, it should redirect them internally to one of the user-accounts inside james itself. I guess there would be a simple solution if would like all mails to get forwareded, but I don't think there is a blacklist syntax so that mails from specific services with non-local recipients got send out.
>
> Currently I'm using 3.2.0 <tel:3.2.0> final release commit. I also looked into the mailetcontainer.xml <http://mailetcontainer.xml> file and I guess it's possible in there to specify this rule:
>
> redirect anything local, except address set in apache config, to user X, otherwise when from apache with non-local target -> transport
>
> Could anyone maybe give me a hint?
> Other solution: redirect anything local from sendmail to processing and with another task process the mails like some short lines of additional Java.
>
> Matt

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





---------------------------------------------------------------------
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