sendmail: forward wildcard MX to a single email address
As you noted, you need a DNS wildcard.
When mail from the wildcard addresses comes in, sendmail doesn't know what to do with it. You can fix that by adding a sendmail rewrite rule to rewrite the wild subdomain parts into the main domain part.
in your sendmail.mc:
LOCAL_NET_CONFIG
R $+ < @ $+ .example.com. > $* $: $1 < @ example.com > $3 dnl
Note that you need a tab to separate the left-hand side rule from the right-hand side replacement. ($*
ends the left-hand side; $:
starts the right-hand side.) Note that the trailing dot on the left-hand side may or may not be necessary. Also note you need a second tab after the right-hand side and the comment (between $3
and dnl
).
You'll want to make sure example.com is in your relay-domains
file.
Once the domain has been collapsed by the rewrite rule, you can route all mail for the domain to a single user with a virtusertable
entry:
@example.com luser
That should about do it.