How to configure linux sendmail server step by step
In a company environment, email is an essential component to the work day. Email is used to communicate with both internal employees and external customers. In exam you will be tested to configure the send mail server for you local LAN.
By default sendmail server allows to connect to local host only. So we should edit the /etc/mail/sendmail.mc file to allow connect to other hosts.
The sendmail daemon is configured from a directory of files in /etc/mail and a directory of configuration files in/usr/share/sendmail-cf. There are two basic configuration files:
- sendmail.cf The main sendmail configuration file.
- sendmail.mc A macro that's easier to edit, which can be used to generate a new sendmail.cf file.
For this example we are using two systems one linux server one linux clients. These are the pre quest for a sendmailserver
- A linux server with ip address 192.168.0.254 and hostname Server
- A linux client with ip address 192.168.0.1 and hostname Client1
- A Configured DNS server on Linux server
- Updated /etc/hosts file on both linux system
- Running portmap and xinetd services
- Firewall should be off on server
We have configured all these steps in our pervious article.
We suggest you to review that article and configure DNS server before start configuration of sendmail server. Once you have completed the necessary steps follow this guide.
Configure sendmail server
sendmail and m4 rpm are required to configure sendmail server check them for install if not found install them.
Mail server program reads the /etc/mail/sendmail.cf. To change the configuration on mail server, we should edit the/etc/mail/sendmail.mc file. When Sendmail is started or restarted with the service sendmail restart command a new sendmail.cf file is automatically generated if sendmail.mc has been modified. In exam you should generate it with m4 command.
open /etc/mail/sendmail.mc for editing
show hidden line with : set nu option on vi command mode
By default, the following line limits sendmail access to connect local host only [line no 116]
You can allow other computers to use your sendmail server by commenting out this line.
In the sendmail.mc file , lines that begin with dnl, which stands for delete to new line, are considered comments. Some lines end with dnl, but lines ending in dnl are not comments
comment this line with dnl keyword followed by # sign
save this file with :wq and exit.
Now generate new sendmail.cf file by using m4 command as shown here
Now restart sendmail service and also set it on with chkconfig
if sendmail service restart without any error means you have configured sendmailsuccessfully.
Configure sendmail client side
We are using another linux system to test sendmail server. All configuration are same as you have done on server system.
Check sendmail and m4 rpm for install. Open /etc/mail/sendmail.mc file and locate line no 116 and put a dnlwith # sing and save file. All step are same which you have done on server.
Now generate new sendmail.cf file by using m4 command as shown here
Now restart sendmail service and also set it on with chkconfig
Testing of sendmail server
We will test sendmail server by sending and receiving mail in lab environment. for this we use two user one on each system.Now create one user on each system vinita on server
and nikita on client system
Now send mail from user vinita to nikita and from nikita to user vinita and also check each others mail by mail command
Use full user name to send mail. For example to send mail to nikita use nikita@client1 and tosend mail to vinita use vinita@server.example.com