Score:1

Setup postfix exclusively for local delivery

sz flag

For development purposes I wanted an smtp server, that simply places all mails into a local mailbox. To achieve this, I tried to setup a minimal postfix system.

# master.cf
smtp      inet       n  - n -     - smtpd
cleanup   unix       n  - n -     0 cleanup
qmgr      unix       n  - n 300   1 qmgr
rewrite   unix       -  - n -     - trivial-rewrite
bounce    unix       -  - n -     0 bounce
defer     unix       -  - n -     0 bounce
trace     unix       -  - n -     0 bounce
verify    unix       -  - n -     1 verify
error     unix       -  - n -     - error
retry     unix       -  - n -     - error
discard   unix       -  - n -     - discard
local     unix       -  n n -     - local
scache    unix       -  - n -     1 scache
proxymap  unix       -  - - -     1 proxymap
postlog   unix-dgram n  - n -     1 postlogd
# main.cf
compatibility_level = 3.7
queue_directory = /var/spool/postfix
command_directory = /usr/bin
daemon_directory = /usr/lib/postfix/bin
data_directory = /var/lib/postfix
mail_owner = postfix
inet_protocols = ipv4
unknown_local_recipient_reject_code = 550

mydestination = localhost
alias_maps = regexp:{{/.*/ mytargetuser@localhost}}
alias_database = $alias_maps

Talking to smtpd is no problem. I get successful responses through the entire conversation, however in the end, postfix tries to use smtp to deliver the mail, which is not enabled:

postfix/smtpd: connect from myhost.mydomain[127.0.0.1]
postfix/smtpd: 8D548E40850: client=myhost.mydomain[127.0.0.1]
postfix/cleanup: 8D548E40850: message-id=<20220506145639.8D548E40850@myhost>
postfix/qmgr: 8D548E40850: from=<[email protected]>, size=408, nrcpt=1 (queue active)
postfix/qmgr: warning: connect to transport private/smtp: Connection refused
postfix/error: 8D548E40850: to=<[email protected]>, relay=none, delay=30, delays=30/0/0/0.01, dsn=4.3.0, status=deferred (mail transport unavailable)

Any clue, why alias_maps is not working as I indended to use it here?

Score:1
fr flag
anx

The (local) alias maps are consulted after determining that the destination is local.

But you told Postfix that only localhost is a local destination, do you also need to adjust your mydestination setting. If any destination is local, this should do the trick:

mydestination=static:all

  • Consider also setting relay_transport=error to make both configuration intent and error handling immediately obvious. You do not want to relay with such configuration.
  • Consider leaving inet_protocols unset (default) and setting inet_interfaces=loopback-only to only serve clients from the very system it is running on. You do not want to receive mail from the wider internet with such configuration.
sz flag
`mydestination=static:anything` works here, which resolves the original problem, thanks. Turns out my attempt was not working either way since the `alias_maps` lookup is recursive and it will end in an infinite loop where it tries to resolve the username. Empty `alias_maps`, `local_recipient_maps` and `luser_relay = myuser` is what does what I was trying to accomplish
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.