Modifying the "from" domain of a message with sendmail

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 address and I needed to convert the "from" address from a 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/ For the example below, I use the domain as the local domain name for the server.


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 "" while a single quote is used after it.

I then regenerated the sendmail configuration file /etc/mail/ by restarting sendmail with service sendmail restart. The server is running CentOS 7, which does not require one to manually regenerate the file with m4 /etc/mail/ > /etc/mail/ - see No longer need to run m4 to rebuild under CentOS7. When you restart sendmail on CentOS 7, if the file has been modified, a new 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 part of his email address,, with, so the "from" address line when viewed from the recipient's inbox was as follows:

From: John Slartibartfast <>

Related articles:

  1. No longer need to run m4 to rebuild under CentOS7
  2. m4 man page
  3. Using a command-line interface (CLI) to send email from mutt


  1. 4.4 Masquerading