Setting up ✉️ Sendmail better method

Setting up ✉️ Sendmail better method

To generate a sendmail configuration file you must edit the file /etc/mail/sendmail.mc (make a copy of it first for future reference). This file is used to generate the sendmail.cf file which is the main sendmail configuration file.

Redhat (and other Linux vendors) will have already created the file /etc/mail/sendmail.mc file and filled it with sensible default values. You will need to modify the following lines, change the line:

dnl define(`SMART_HOST',`smtp.your.provider')

to

define(`SMART_HOST',`pop.yourchoice.com')

The dnl is used to signify a comment, which means everything after the dnl will be ignored, therefore after setting the SMART_HOST variable you should remove the dnl from the start of the line.

The only other change you need to make to this file is to comment out the line:

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

by placing a dnl at the start of the line:

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

This line makes sendmail only accept e-mail to and from the local machine. To accept e-mail from other machines on the Internet the line should be removed, which is done by commenting it out.

You can now generate your new sendmail.cf file. To do this issue the command (as root):

m4 sendmail.mc > sendmail.cf

This will create the sendmail configuration file. It should be placed in the /etc/mail/ directory (or the /etc/ directory for older Linux distributions). You can now start sendmail with the command (as root):

/etc/rc.d/init.d/sendmail restart

(some Linux distributions will use different commands to this).

whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.