How to Configure and Setup a Sendmail Server – A step by step Guide
Sendmail server comes default with LinuxÂ flavors. Â Sendmail is an email routing application forÂ LinuxÂ operating systems.Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and -delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the Internet.
Sendmail is the most popular mail transfer agent (MTA) on the Internet. Its popularity is due in part to its position as the standard MTA under most variants of the Unix and other Unix-like operating system.
Allman had written the original ARPANET delivermail which shipped in 1979 with 4.0 and 4.1 BSD. He wrote Sendmail as a derivative of delivermail early in the 1980s at UC Berkeley. It shipped with BSD 4.1c in 1983, the first BSD version that included TCP/IP protocols.
Here i am going to explain about configuration ofÂ SendmailÂ for bulk mail sending. There are couple of steps you need to follow to get it work as well as the mail should not go to spam folder of theÂ Recipient.
How to setup a bulk mail send mail server
We canÂ divideÂ this in two as follows.
- Configuration of Sendmail
- White-listingÂ of yourÂ SendmailÂ server
First lets discuss aboutÂ ConfigurationÂ of Sendmail Server.
The Sendmail get installed by default on linux systems. Â Just start the service by typing the following any of the command
service sendmail start /etc/init.d/sendmail restart
Follow the step by step Now to configureÂ SendmailÂ server
a) Type the command following commandÂ to open the “resolv.conf” file in a text editor
vi /etc/resolv.conf or gedit /etc/resolv.conf
Then add theÂ dns serverÂ in the resove.conf file. The dns plays a big role in sending the mails toÂ recipientÂ domain. if name server is not working then your mail server will not deliver any mails to theÂ recipients. You can add the nameserver by adding the following line in the resolv.conf file.
(18.104.22.168 isÂ GoogleÂ dns, if you are not having aÂ name serverÂ then you can use it.)
b) Type the command “gedit /etc/mail/sendmail.mc” to open the “sendmail.mc” file in a text editor.
Change the “Addr” variable in the line “dnl DAEMON_OPTIONS(‘Port=smtp,Addr=127.0.0.1, Name=MTA’)” to reflect the IP address of your Â Â Â Â Â Â Â mail server. Remove the “dnl” characters in front of the line. Â You can see the screenshot of the same as below..
c) Open the “/etc/mail/access” file in a text editor. Place the IP address and domain name of the computers and domains that can relay mail Â Â Â Â Â through your server in the file. Â Â Once you have added the same the file will look like shown below…
# Check the /usr/share/doc/sendmail/README.cf file for a description# of the format of this file. (search for access_db in that file)# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc# package.## by default we allow relaying from localhost...Connect:localhost.localdomain RELAYConnect:localhost RELAYConnect:127.0.0.1 RELAY172.16.1.21 RELAY172.16.1.22 RELAY172.16.1.23 RELAY172.16.1.24 RELAY172.16.1.29 RELAY172.16.1.30 RELAY172.16.1.4 RELAY172.16.1.114 RELAY172.16.1.124 RELAY
d) Type the following commands to reconfigure sendmail:
cd /etc/mail make newaliases /etc/init.d/sendmail restart
We have done withÂ SendmailÂ configuration. Now let us discuss withÂ White-listingÂ of yourÂ SendmailÂ server.
Follow the below listed steps to White-listing the SendmailÂ server
a) The first step is to Nat an live ip address with theÂ SendmailÂ server. This you canÂ achieveÂ in the firewall Â by making a Nat configuration. This will help your Sendmail server to use this ip in the internet to deliver the mails.
b) The second step is to make dns entry for yourÂ SendmailÂ server. suppose your server name is abcd.xyz.com then you have to do an dns entry for this name with the nated ip address. Remember to make reverse entry also. Once the entry is done you have to verify it . see the below shown example.
> peab3.abcd.com Server: Â Â Â Â 172.16.1.30 Address: Â Â Â Â 172.16.1.30#53 Non-authoritative answer: Name: Â peab3.abcd.com Address: 123.108.00.240
> Â 123.108.00.240 Server: Â Â Â Â 172.16.1.30 Address: Â Â Â Â 172.16.1.30#53 Non-authoritative answer: 240.00.108.123.in-addr.arpa Â Â name = peab3.abcd.com.
first when i did an nslookup with my server name. it got resolved toÂ 123.108.00.240 . Then i did nslookup with ip then it got resolved to name. so your settings should be like this.
c) The last step is to create an SPF record. please see the following article to create an SPF Record.