Saturday, November 24, 2007


Hi friends

This article explains the basic configuration of sendmail. In this example, i use the sendmail package from the RHEL 5 and use and as fqdn for this mail server and dns server. Lemme give you the step by step procedure for building the sendmail server.

1. Install the sendmail package:

# yum install sendmail

2. Check the Existence of package:

# rpm -qa | grep sendmail

3. Services:

# chkconfig --level 345 sendmail on
# service sendmail start|stop|restart|status or
# /etc/init.d/sendmail start|stop|restart|status

4. Sendmail configuration file :

# /etc/mail/ //main sendmail config file
# /etc/mail/ //file used to edit and push the updates to the main file

All configuration changes can be done only at /etc/mail/ and with the help of macro push it to the file /etc/mail/

5. Macro m4 :

To find the macro path
# locate cf.m4
#m4 /usr/share/sendmail-cf/m4/cf.m4 /etc/mail/ > /etc/mail/
and then restart to make the changes to take effect.

6. Disabling line in /etc/mail/ file:

These statements are disabled by dnl commenting.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')

This statement is incorrectly disabled:
# DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')

This statement is active:
DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')

7. DNS Server

The proper implementation of DNS server is important before configuring the sendmail. Please test the dns name resoultion with the tools like nslookup, host and dig tool.In this eg, consider the ( as primary dns server.

# host has address
#host address

8. Check /etc/resolv.conf file:
make sure /etc/resolv.conf file contains the correct dns server details
# vi /etc/resolv.conf

9. Check /etc/hosts file:
# vi /etc/hosts localhost.localdomain localhost mailserver

10. Edit /etc/mail/ file:

First, using dnl disable the line like
dnl "DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')"

Second, disable the smarthost option
dnl define(`SMART_HOST',`')

Use macro and restart the sendmail daemon

Check the local NIC card is enabled for receive all packets by
# netstat -an | grep :25 | grep tcp
tcp 0 0* LISTEN

11. Edit /etc/mail/access file:

# vi /etc/mail/access
localhost.localdomain RELAY
localhost RELAY RELAY
192.168.30 REJECT // rejects the mails from n/w RELAY // relay the mails from the host
192.168.10 RELAY // relay the mails from n/w RELAY // relay the mails from the suffix

12. Edit /etc/mail/local-host-names file:

add hostnames or domain names for which the sendmail accept mail for local delivery.

# vi /etc/mali/local-host-names

13. Edit /etc/mail/virtusertable file:

# vi /etc/mail/virtusertable
// first column is the target email address
// second column may be created user mailbox in the mailserver, aliase name or groupname created in the /etc/aliase or even remote email address. logu // logu - local user sonia test testaliase // testaliase entry created in /etc/aliase error:nouser User Unknown // answer for other than the above user

14. Edit /etc/aliases file:

add the below lines at the bottom of the file

# vi /etc/aliases

#setting new aliase
testaliase: logu,test

As per virtusertable above, the mail to will go to and

15. Configuring POP3/IMAP :
By configuring the sendmail for pop3/imap, we will be able to acces mail from thunderbird, evolution, Outlook, etc.

First, check the existence of dovecot and services using

# chkconfig --level 345 dovecot on
# service dovecot start|stop|restart|status or
# /etc/init.d/dovecot start|stop|restart|status

Second, edit the /etc/dovecot.conf file

# vi /etc/dovecot.conf
//search for protocols
//protocols = imap imaps pop3 pop3s
protocols = pop3 // configure pop3 or imap as per your need

Third, test the NIC listening for pop3 using,

# netstat -a | egrep -i 'pop|imap'
tcp 0 0 *:pop3 *:* LISTEN

Fourth, use Outlook or any client tool to test the mail flow.

16. Troubleshooting via telnet:

Please refer this article in my blog.


No comments: