How to configure a real domain name for sender address
I think I have just solved it. I have the following in /etc/hosts:
127.0.0.1 www.mydomain.com test.mydomain.com
127.0.0.1 cdn.mycdn.com
127.0.0.1 localhost.localdomain localhost myserver.com
What I need is to place myserver.com in front of the line with localhost.localdomain
so that sendmail will think that it is using a real domain to send out the email.
You have to configure, in your scripts, the headers of your email to have From: [email protected]
.
In my case, on Ubuntu 16.04 on an AWS instance, what was needed was to add to /etc/mail/sendmail.mc
:
define(`confDOMAIN_NAME', `mydomainname.com')dnl
on a line before the MAILER_DEFINITIONS
line toward the end of the file, AND add the same line to the end of /etc/mail/submit.mc
. Then type sudo su
for root permissions, and compile to config with:
m4 sendmail.mc > sendmail.cf
m4 submit.mc > submit.cf
...then exit
sudo. Finally, sudo service sendmail restart
to restart sendmail, and from thereon emails were appearing as sent from the domain name. None of the other FEATURE or MASQUERADE commands were required, nor an entry in the /etc/hosts
file.