Sendmail: catchall for all domains

sendmailsles11

I need to set up a mail server config for a test environment which would accept all mail (i.e. for all users and all domains, even non-local ones) and put it into a single local catchall mailbox.

What I have is SLES 11 with Sendmail (8.14) where I tried modifying /etc/mail/virtusertable to look like

@ catchall

or like

@* catchall

but to no avail – destination mail addresses (e.g. "santa@northpole.org") are not rewritten to catchall@, so delivery is tried to the appropriate MX:

# sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> 3,0 santa@northpole.org
canonify           input: santa @ northpole . org
Canonify2          input: santa < @ northpole . org >
Canonify2        returns: santa < @ northpole . org . >
canonify         returns: santa < @ northpole . org . >
parse              input: santa < @ northpole . org . >
Parse0             input: santa < @ northpole . org . >
Parse0           returns: santa < @ northpole . org . >
ParseLocal         input: santa < @ northpole . org . >
ParseLocal       returns: santa < @ northpole . org . >
Parse1             input: santa < @ northpole . org . >
MailerToTriple     input: < > santa < @ northpole . org . >
MailerToTriple   returns: santa < @ northpole . org . >
Parse1           returns: $# esmtp $@ northpole . org . $: santa < @ northpole . org . >
parse            returns: $# esmtp $@ northpole . org . $: santa < @ northpole . org . >

It seems like wildcards are not supported in the source domain part of the lookup table.

How would I implement this with Sendmail?

Edit: As per Andrzej's comments I have tried a mailertable entry of

. local:catch-all-outgoing

as well as

.. local:catch-all-outgoing

and received identical output for sendmail -bv in both cases:

# sendmail -d60.5 -bv jd@example.net
map_lookup(dequote, root, %0=root) => NOT FOUND (0)
map_lookup(host, example.net, %0=example.net) => example.net. (0)
jd@example.net... deliverable: mailer esmtp, host example.net., user jd@example.net

(yes, root, as sendmail seems unable to run as non-root)

Edit: it turned out, the mailertable feature has not been enabled in the macro file, thus sendmail.cf did not contain the appropriate rewrite rules for it to work.

Best Answer

What you are running into here: /etc/mail/virtusertable I believe is limited to inbound email only, not outbound.

You can use default route in mailertable or SMART_HOST to deliver all non local messages to one local mailbox/alias.

mailertable entry:
. local:catch-all-outgoing

aliases:
catch-all-outgoing: some-local-account

Any LHS entry that does not begin with a dot matches the full host name indicated. LHS entries beginning with a dot match anything ending with that domain name (including the leading dot) -- that is, they can be thought of as having a leading ".+" regular expression pattern for a non-empty sequence of characters.

The RHS should always be a "mailer:host" pair. The mailer is the configuration name of a mailer (that is, an M line in the sendmail.cf file). The "host" will be the hostname passed to that mailer.

(reference: sendmail readme, "USING MAILERTABLES" section)

So something like:

. local:catch-all-outgoing (just a single dot as per Adrzej's comment) in /etc/mail/mailertable should cause any domain.tld to redirect to the local mailer config defined in sendmail.cf. With the alias catching the hostname of catch-all-outgoing and causing it to be a local email address.

For the mailertable to work, it needs to be enabled in the config. Adding

FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl

to the m4 macro file generating your config should take care of that.

Also from the sendmail site help files:

MAILERTABLE:

Include a "mailer table" which can be used to override routing for particular domains (which are not in class {w}, i.e. local host names). The argument of the FEATURE may be the key definition. If none is specified, the definition used is:

hash /etc/mail/mailertable

Keys in this database are fully qualified domain names or partial domains preceded by a dot -- for example, "vangogh.CS.Berkeley.EDU" or ".CS.Berkeley.EDU". As a special case of the latter, "." matches any domain not covered by other keys. Values must be of the form: mailer:domain

where "mailer" is the internal mailer name, and "domain" is where to send the message. These maps are not reflected into the message header. As a special case, the forms: local:user will forward to the indicated user using the local mailer,