Rewriting Sender addresses for Entire Domain in Sendmail

  1. Edit /etc/mail/sendmail.mc and add the below lines replacing domain.tld with the actual domain name:

    dnl # BEGIN: Rewriting Sender addresses for Entire Domain
    dnl #
    dnl # Process login names through the genericstable
    FEATURE(`genericstable', `hash -o /etc/mail/genericstable.db')dnl
    dnl # Interpret the value in G as a domain name
    FEATURE(generics_entire_domain)dnl
    dnl # masquerade not just the headers, but the envelope as well
    FEATURE(masquerade_envelope)dnl
    dnl # Load domain.tld into G
    GENERICS_DOMAIN(domain.tld)dnl
    dnl #
    dnl # END: Rewriting Sender addresses for Entire Domain

  2. Create /etc/mail/genericstable, which is very similar to an /etc/aliases, two columns separated by whitespace:

    web1_user1    user1@domain.tld
    web1_user2    user2@domain.tld
    web1_user3    user3@domain.tld

  3. Create the db:

    # makemap -hash /etc/mail/genericstable < /etc/mail/genericstable

  4. Restart sendmail.

Feature "genericstable" tells sendmail to use the generics table.

Feature "generics_entire_domain" allows to add hosts to genericstable without having to rebuild sendmail.cf.

Feature "masquerade_envelope" applies the rewriting process to the mail envelope as well as to the mail header.

"GENERICS_DOMAIN" defines the domains to which you wish to apply the generics table.

References:

madboa.com
brandonhutchinson.com
lege.com
cyberciti.biz

Comment