A user sends a monthly email newsletter to a distribution list on an email
server I maintain that uses sendmail. He sends the message to an
email alias
on the system where sendmail converts the alias to all of the email
addresses in the mailing list and the sends it out through a
smart host to be
delivered to all of the recipients of the newsletter. The sender sends the
message from his verizon.net address and I needed to convert the "from"
address from a verizon.net email address to a local email address on the
server running sendmail. To do so, I placed the following lines at the
end of /etc/mail/sendmail.mc
. For the example below, I use the
example.com domain as the local domain name for the server.
MASQUERADE_DOMAIN(`verizon.net')dnl MASQUERADE_AS(`example.com')dnl
Note: the "dnl" at the end of each line has the letter "l", not the
number "1" at the end of the line. And a
backtick, i.e., `
, is used before
"verizon.net" while a single quote is used after it.
I then regenerated the sendmail configuration file
/etc/mail/sendmail.cf
by restarting sendmail with
service sendmail restart
. The server is running
CentOS 7,
which does not require one to manually regenerate the
sendmail.cf
file with m4 /etc/mail/sendmail.mc >
/etc/mail/sendmail.cf
- see
No longer need to run
m4 to rebuild sendmai.cf under CentOS7. When you restart sendmail on CentOS
7, if the sendmail.mc file has been modified, a new sendmail.cf file will
automatically be created. But you may need to run that
m4 command with other
operating systems, or prior versions of CentOS, prior to restarting sendmail.
# service sendmail restart Redirecting to /bin/systemctl restart sendmail.service #
Since the mutt email client allows one to specify the "from" line for email messages - see Using a command-line interface (CLI) to send email from mutt - I used it to verify the email address conversion was working correctly. Then when the user sent an email for the newsletter, sendmail replaced the verizon.net part of his email address, johnslartibartfast444@verizon.net, with example.com, so the "from" address line when viewed from the recipient's inbox was as follows:
Related articles:
References: