I'm trying to have smtpd:
1. Deliver mail directly to existing users
2. Otherwise fall back to the contents of /etc/mail/aliases
3. Otherwise fall back to a catch-all that sends all mail to me
I can't seem to figure it out.
According to table(5), to use a catch-all I must use a "virtual context", which
means smtpd(8)'s 'virtual' keyword. But with this, the catch-all takes
precedence over *all* mail and mail *only* comes to me, not to my other users:
# echo '@ kousu' > /etc/mail/catchall
# cat /etc/mail/smtpd.conf
[...]
table catchall file:/etc/mail/catchall
[...]
action "inbound" maildir virtual <catchall>
[...]
match from any for domain "kousu.ca" action "inbound"
[...]
# ls /home/ # these users should be able to receive mail directly
_sysupgrade oxford jane kousu test1 test2
comms3# smtpd -d
info: OpenSMTPD 7.0.0 starting
b2412232263c0878 mta connecting address=smtp+tls://XXX.XXX.XXX.XXX:25
host=mail.example.ca
b2412233f0b9eead smtp connected address=XXX.XXX.XXX.XXX host=mail.example.ca
b2412233f0b9eead smtp tls ciphers=TLSv1.3:TLS_AES_256_GCM_SHA384:256
b2412233f0b9eead smtp message msgid=e3c3d9c7 size=902 nrcpt=1 proto=ESMTP
b2412233f0b9eead smtp envelope evpid=e3c3d9c7d8532695 from=<[email protected]>
to=<[email protected]>
b2412236b38065b9 mda delivery evpid=e3c3d9c7d8532695 from=<[email protected]>
to=<[email protected]> rcpt=<[email protected]> user=kousu delay=2s result=Ok
stat=Delivered
b2412233f0b9eead smtp message msgid=e39f6445 size=902 nrcpt=1 proto=ESMTP
b2412233f0b9eead smtp envelope evpid=e39f6445ff6aca0c from=<[email protected]>
to=<[email protected]>
b2412238cd9028f2 mda delivery evpid=e39f6445ff6aca0c from=<[email protected]>
to=<[email protected]> rcpt=<[email protected]> user=kousu delay=2s result=Ok
stat=Delivered
I'm happy it mapped [email protected]: kousu, but unhappy it also mapped
[email protected]: kousu.
And on the other hand, if I try to add the catch-all to /etc/mail/aliases, it's
silently ignored (table(5) documents this, though it took me a moment to
realize that's what it was saying)
# echo '@ kousu' >> /etc/mail/aliases
# cat /etc/mail/smtpd.conf
table aliases file:/etc/mail/aliases
[...]
action "inbound" maildir alias <alias>
[...]
match from any for domain "kousu.ca" action "inbound"
[...]
comms3# smtpd -d
info: OpenSMTPD 7.0.0 starting
0b519d1a49e4ee04 mta connecting address=smtp+tls://XXX.XXX.XXX.XXX:25
host=mail.example.ca
0b519d1b1de1a199 smtp connected address=XXX.XXX.XXX.XXX host=mail.example.ca
0b519d1b1de1a199 smtp tls ciphers=TLSv1.3:TLS_AES_256_GCM_SHA384:256
0b519d1b1de1a199 smtp message msgid=de68177e size=902 nrcpt=1 proto=ESMTP
0b519d1b1de1a199 smtp envelope evpid=de68177ebd58d3b2 from=<[email protected]>
to=<[email protected]>
0b519d1ccba260c0 mda delivery evpid=de68177ebd58d3b2 from=<[email protected]>
to=<[email protected]> rcpt=<[email protected]> user=jane delay=2s result=Ok
stat=Delivered
0b519d1b1de1a199 smtp failed-command command="RCPT TO:<[email protected]>"
result="550 Invalid recipient: <[email protected]>"
Here it mapped [email protected]: jane, which I'm happy for, but it mapped
[email protected]: /dev/null, which is no good.
I also tried adding a second 'match' and a second 'action',
# cat /etc/mail/smtpd.conf
table aliases file:/etc/mail/aliases
[...]
action "inbound" maildir alias <alias>
action "inbound-catchall" maildir "~/.mail/" virtual <catchall>
[...]
match from any for domain "kousu.ca" action "inbound"
match from any for domain "kousu.ca" action "inbound-catchall"
But this just ignores the second match, behaving the same as the 'alias' case;
and if I swap the order then it behaves the same as the 'virtual' case.
So, Question: how do I set up a fall-back catch-all with opensmtpd?
And some follow-ups:
Question: are 'alias' and 'virtual' mutually exclusive? The smtpd.conf(5)
manpage doesn't state this explicitly, but if I try it it fails:
# cat /etc/mail/smtpd.conf
table aliases file:/etc/mail/aliases
table catchall file:/etc/mail/catchall
[...]
action "inbound" maildir virtual <catchall> alias <alias>
[...]
match from any for domain "kousu.ca" action "inbound"
[...]
# smtpd -d
/etc/mail/smtpd.conf:27: virtual mapping already specified for this dispatcher
/etc/mail/smtpd.conf:40: no such dispatcher: inbound
/etc/mail/smtpd.conf:41: no such dispatcher: inbound
Question: It seems like 'virtual' can do everything 'alias' can, so is 'alias'
deprecated?
Question: aliases(5), and the default /etc/mail/aliases, show the format has
colons (:) in it:
# cat /etc/mail/aliases
[...]
# RFC 2142: NETWORK OPERATIONS MAILBOX NAMES
abuse: root
# noc: root
security: root
[...]
but table(5) doesn't show any colons. smtpd seems to be able to handle either
with or without colons; is one supposed to be more canonical than the other?
For reference, I'm on:
# uname -a
OpenBSD comms3.kousu.ca 7.1 GENERIC#3 amd64
Thanks in advance! Hope you're having a chill day
(and please CC me, I'm not subscribed)
-Nick