Search code examples
sendmail

Sendmail catchall for sending messages


I am trying to change my development environment so that any emails sent from my machine through sendmail are redirected to a single address.

I have seen several examples using FEATURE(`virtusertable') like this

@example.com          [email protected]

but the problem is I want to catch EVERYTHING, not just @example.com, and redirect it to a single address on an external domain (gmail). Currently I have sendmail setup on CentOS 6.5.

So, for example, I want to catch an emails that could be sent to

[email protected]
[email protected]
[email protected]

and redirect them to

[email protected]

How do I set sendmail up to do that?


Solution

  • You may use smart host to catch all outgoing messages (messages to non local mailboxes).

    sendmail.mc

    dnl Send all no local emails to local email address catch-all 
    define(`SMART_HOST',`local:catch-all')
    

    /etc/mail/aliases

    # define catch-all alias
    catch-all:  johndeveloper1, archive
    

    If you want to send messages to an external account using smtp then use:

    define(`SMART_HOST',`esmtp:[email protected]')
    

    Use LUSER_RELAY to catch messages to non existing local mailboxes in local email domains.

    Use MAIl_HUB to catch messages to all local email addresses in local email domains.

    More complicated recipes allow to copy all envelope recipient addresses to email headers.