Many years ago, I distributed email to the mailing list for an organization through my email server. The person who sent out a monthly newsletter to the members of the organization had a Verizon email address and would send the newsletter via my server running Sendmail, which would then send the mail onwards to the organization's members. Since my server wasn't a designated email server for verizon.net addresses, I configured Sendmail to change the "from" domain to my server's domain name, moonpoint.com, so the sending address wouldn't be johnslartibartfast444@verizon.net but would be johnslartibartfast444@moonpoint.com; otherwise many recipients' email servers would reject the email since it didn't come from an email server designated to send email for verizon.net users. I put the following lines in /etc/mail/sendmail.mc (the last two lines are the ones I added to the Masquerade section of the file):
dnl # The following example makes mail from this host and any additional dnl # specified domains appear to be sent from mydomain.com dnl # dnl MASQUERADE_AS(`mydomain.com')dnl dnl # dnl # masquerade not just the headers, but the envelope as well dnl # dnl FEATURE(masquerade_envelope)dnl dnl # dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well dnl # dnl FEATURE(masquerade_entire_domain)dnl dnl # dnl MASQUERADE_DOMAIN(localhost)dnl dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl dnl MASQUERADE_DOMAIN(mydomain.lan)dnl MAILER(smtp)dnl MAILER(procmail)dnl dnl MAILER(cyrusv2)dnl MASQUERADE_DOMAIN(`verizon.net')dnl MASQUERADE_AS(`moonpoint.com')dnl
After I edited the sendmail.mc file, I rebuilt the sendmail.cf
file by restarting sendmail with the command service sendmail
restart , which put the following line in sendmail.cf:
C{M}verizon.net
The person who was sending the newsletter died several years ago
and I took over maintaining the membership list for the organization as
well as distributing the email version of the newsletters to members.
Though the account from which the newsletter is sent is intended to be
used only for sending the newsletter and members are advised to send an
email related to the organization to the organization's Gmail email addresses,
occasionally members will reply directly to the "from" address used for
the newsletter. When checking the account for that address, I found that someone
with a verizon.net address had sent a reply to the account, but if I replied
my reply would go not to his verizon.net address, but to his email name
followed by my domain name, which would result in the email bouncing since
that address would not be a valid address on my server. I corrected the
problem by removing the two MASQUERADE lines in sendmail.mc that resulted
in the change to the domain name part of email addresses if any email
came from a verizon.net address and then restarted sendmail, which resulted
in the C{M}verizon.net line being removed from sendmail.cf.
The sendmail.mc file is a human-readable macro configuration file, while the sendmail.cf file is the more complex configuration file actually used by the
Sendmail message
transfer agent (MTA). The .mc file serves as the source, which is processed
by the m4
macro to generate the final, often uncommented sendmail.cf file used by
sendmail. The command m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
can be used to rebuild the .cf configuration file after one makes
changes to the sendmail.mc file, but the changes won't take effect until
sendmail is restarted. Or, on many newer versions of the Linux operating
system, one can simply restart sendmail and a new .cf file will be
automatically generated and applied to sendmail, if any changes have been made
to the .mc file
References:
Related articles:
-
Modifying the "from" domain of a message with sendmail
Date: June 1, 2018
