Configure sendmail to enable masquerading

Find out which configuration file sendmail is using.

# cat /var/run/sendmail.pid
12345
/usr/sbin/sendmail -L sm-mta -C/etc/mail/localhost.cf -bd -q30m

Make a backup copy of the original configuration file

# cp /etc/mail/localhost.cf /etc/mail/localhost.cf_original

Go to the directory containing the sendmail configuration files

# cd /usr/share/sendmail/cf

A look at /etc/mail/localhost.cf will tell you that it is derived from openbsd-localhost.mc

So, let's make a copy of that configuration file ...

# cp openbsd-localhost.mc myconfig.mc

... and modify it

# vi myconfig.mc

To enable masquerading for domain 'mydomain.tld', we could add the following lines to myconfig.mc

MASQUERADE_AS(`mydomain.tld')dnl
FEATURE(`masquerade_envelope')dnl
FEATURE(`masquerade_entire_domain')dnl
MASQUERADE_DOMAIN(`mydomain.tld')dnl

Save myconfig.mc after the required changes have been made and convert it to the .cf file

# m4 ../m4/cf.m4 myconfig.mc myconfig.cf

Overwrite the existing configuration

# cp myconfig.cf /etc/mail/localhost.cf

And restart sendmail

# kill -HUP 12345