What is Sendmail?
Sendmail is a mail server used for sending and receiving mails. It works on SMTP (Simple Mail Transfer Protocol ) protocol on port 25.
Most of users are familier with sendmail and want to use it also. This article will help that users for installing sendmail server on RHEL 6 or with minimal configuration.
How it works?
1. Incoming Mail
Usually each user in your home has a regular Linux account on your mail server. Mail sent to each of these users (email@example.com) eventually arrives at your mail server and sendmail then processes it and deposits it in the mailbox file of the user’s Linux account. Mail isn’t actually sent directly to the user’s PC. Users retrieve their mail from the mail server using client software, such as Microsoft’s Outlook or Outlook Express, that supports either the POP or IMAP mail retrieval protocols.
Linux users logged into the mail server can read their mail directly using a text-based client, such as mail, or a GUI client, such as Evolution. Linux workstation users can use the same programs to access their mail remotely.
2. Outgoing Mail
The process is different when sending mail via the mail server. PC and Linux workstation users configure their e-mail software to make the mail server their outbound SMTP mail server.
If the mail is destined for a local user in the “xyz.com” domain, then sendmail places the message in that person’s mailbox so that they can retrieve it using one of the methods above.
If the mail is being sent to another domain, sendmail first uses DNS to get the MX record for the other domain. It then attempts to relay the mail to the appropriate destination mail server using the Simple Mail Transport Protocol (SMTP). One of the main advantages of mail relaying is that when a PC user A sends mail to user B on the Internet, the PC of user A can delegate the SMTP processing to the mail server.
What you need before set up sendmail?
Most important tasks in setting up DNS for your domain (xyz.com) is to use the MX record in the configuration zone file to state the hostname of the server that will handle the mail for the domain.
Install the following dependent package:
# yum install m4 telnet mailx
Install the sendmail and few required packages using yum
# yum install sendmail sendmail-cf
- By default sendmail configuration files are located at /etc/mail.
- By default sendmail listen on local interface i.e 127.0.0.1, check using this command:
# ps -ef | grep -v grep | grep -i sendmail
root 3595 1 0 00:20 ? 00:00:00 sendmail: accepting connections
smmsp 3604 1 0 00:20 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
# netstat -an | grep :25 | grep tcp
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
- To configure the sendmail to listen to all interface at the host, just comment the following line in“sendmail.mc”:
# vi /etc/mail/sendmail.mc
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl
- Now we need to build the “sendmail.cf” file using m4 macro:
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
- Restart Sendmail Service:
# service sendmail restart
- Adding your domain entry in “/etc/mail/local-host-names” file:
Add all domains for which you will accept mail; there should be one domain per line.
For example, if this mail server was to accept mail for the domains “abc.com”,”xyz.co.in”
# vi /etc/mail/local-host-names
- Make a entry for it to start at boot time and restart the service of sendmail and:
# chkconfig sendmail on
# service sendmail restart
- Check if sendmail is installed or not:
# rpm –qa | grep sendmail
- Create two test user for testing purpose to send and receive mail.
# useradd test1
# useradd test2
- Login as one of the user (say test1) and try to send mail using mail command:
$ mail -s “Test mail from test1” test2
Hello this is the test mail
- Now we need to check the Maillog “/var/log/maillog” in case of any issue
# tail /var/log/maillog
- Once mail has been delivered successfully now we need to check if mail is delivered to user (test2) mailbox or not
You can see the output as below:
N 1 firstname.lastname@example.org SUN SEP 19 01:07 13/503 “Sendmail Test”
- 46Mail Us:- email@example.com firstname.lastname@example.org Visit Us: http://inetextech.com Call Us : | Mail Us : email@example.com Our Services: IVR design and development Open Source Dialer installation and Support International / Domestic Call center setup Voice Broadcasting SMS Misscall services We are Delhi based organisation that offers various service like on-line…