I'm trying to setup a Postfix (2.11.4) configuration so that it does this:
- Sends out mail originating from the local server
- Accepts incoming mail for a single alias, which actually points to a script
- And nothing else
Here's a partial main.cf:
mydomain = example.com
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
relayhost = outbound.example.com
allow_mail_to_commands = alias,forward,include
allow_mail_to_files = alias,forward,include
luser_relay = $local@example.com
For #1, mail generated on the server for someone@example.com automatically gets sent to "outbound.example.com" for processing. And for #2, I have this in /etc/postfix/aliases , so messages to "robot@myserver.example.com" can be processed by a Perl script
robot: | "/usr/local/bin/robomail.pl"
So far so good. It's #3 that is giving me trouble.
See, this server used to run Sendmail with domain masquerading turned on. And there are still some apps on this server (which I do not control) that send e-mail to just "george" (for example) and expect the server to convert that automatically to "george@example.com", which then gets routed to "outbound.example.com" for delivery.
I tried to fix this by setting up a luser_relay
directive:
luser_relay = $local@example.com
This sort of works - when local delivery to "george" fails, Postfix will rewrite it to george@example.com
But if "george" is actually a valid account on the server (i.e. listed in /etc/passwd), then Postfix will accept the message and deliver it to a local mail directory, instead of rewriting the address and forwarding it.
I can work around this by making another /etc/postfix/aliases entry:
george: george@example.com
But this is obviously not scalable when the server has dozens of local user accounts, with more being added all the time. And as best I can tell from the documentation, there's no wildcard equivalent for /etc/postfix/aliases. Otherwise, I would want to do something like this:
robot: | "/usr/local/bin/robomail.pl"
*: *@example.com
Is there a way in Postfix to do this? Accept mail for "robot", but forward everything else to "outbound.example.com" for delivery (adding the @example.com if necessary)?
UPDATE: Some postconf details, and the log of a message that gets sent from "root" to "george" on the local server:
myhostname = myserver.example.com
myorigin = $myhostname
masquerade_domains =
Mar 23 14:07:26 myserver postfix/pickup[12851]: D2B4A4763D: uid=0 from=<root>
Mar 23 14:07:26 myserver postfix/cleanup[19630]: D2B4A4763D: message-id=<20150323190726.D2B4A4763D@myserver.example.com>
Mar 23 14:07:26 myserver postfix/qmgr[29583]: D2B4A4763D: from=<root@myserver.example.com>, size=323, nrcpt=1 (queue active)
Mar 23 14:07:26 myserver postfix/local[19632]: D2B4A4763D: to=<george@myserver.example.com>, orig_to=<george>, relay=local, delay=0.04, delays=0.02/0/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox)
Mar 23 14:07:26 myserver postfix/qmgr[29583]: D2B4A4763D: removed