To run multiple domains on one machine, I haven’t found it possible to selectively use domain masquerading to set the correct domain name for email accounts that are part of each domain. However, the genericstable approach allows you to remap email addresses to alternative addresses as emails are sent:
Add these statements to your /etc/mail/sendmail.mc file to enable genericstable:
FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl
Create a /etc/mail/generics-domains file that contains a list of the domains that are to be processed when remapping addresses.
Create the /etc/mail/genericstable file. For example:
Rebuild the genericstable.db file:
makemap hash /etc/mail/genericstable.db < /etc/mail/genericstable
Rebuild your sendmail config using m4 (see other post here).
Restart your sendmail server.