Common Sendmail Issues

** DSN: Service unavailable**

RESOLUTION: set hostname other than localhost



Relay host :

open /etc/mail/sendmail.mc  and configure SMART HOST to your relay and remove the dnl at the front.

vi /etc/mail/sendmail.mc

dnl define(SMART_HOST', relayserver.domain.com')dnl

make it look like :

define(SMART_HOST', relayserver.domain.com')dnl

save and exit

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

[ if you get this error: sendmail.mc:10: m4: cannot open `/usr/share/sendmail-cf/m4/cf.m4′: No such file or directory , you have to install sendmail-cf package ]


To change the From user in mails :

you will have to enable this feature first:

vi /etc/mail/sendmail.mc

FEATURE(masquerade_envelope)dnl FEATURE(genericstable')dnl GENERICS_DOMAIN(localhost.localdomain')dnl

vi /etc/mail/genericstable root test@servername.com


Setup Authentication relay for Sendmail :

vi /etc/mail/access AuthInfo:relay.dnsexit.com "U:USERNAME" "P:PASSWORD" "M:PLAIN"

Add following lines to /etc/mail/sendmail.mc  ( it could be #dnl (‘SMART_HOST’,’xxx ) dnl , you have to remove the # sign at the begining :

vi /etc/mail/sendmail.mc define(SMART_HOST', relay.dnsexit.com') FEATURE(`access_db')

Update sendmail.cf and access.db files

cd /etc/mail m4 sendmail.mc >sendmail.cf


IP Relay with Sendmail :

vi /etc/mail/access

Add the ip there in the format :

<ip_address to relay> RELAY

Map the new hash file :

makemap hash /etc/mail/access < /etc/mail/access


**Setting IP on which sendmail Listens : **

Go and edit /etc/mail/sendmail.mc in your favourite text editor (as root of course) Find the line that reads:

DAEMON_OPTIONS('Port=smtp,Addr=127.0.0.1, Name=MTA')

Now you have two options here. You can replace 127.0.0.1 with the IP address you wish to use or simply place dnl at the front of the line which will make sendmail listen on all available network interfaces. e.g:

dnl DAEMON_OPTIONS('Port=smtp,Addr=127.0.0.1, Name=MTA')

Once this is done save the exit the editor and save the file. Then run  the following command as root:

m4 /etc/mail/sendmail.mc > /etc/sendmail.cf service sendmail restart


Check if an email is deliverable with sendmail

/usr/lib/sendmail -bv root