Page 1 of 1

Configuring Sendmail on RHEL5

Posted: Tue Apr 07, 2009 1:29 pm
by CyberBob
There are various mail servers popular now a days. Once i heard that You are not a system admin if you have not configured Sendmail once, you are crazy if you configured it twice. Sendmail is one of the oldest mail servers. There are other different mail servers which are popular now a days but Nix* lovers still use sendmail as they beleive
"Old is Gold". Please Contact me so that i can improve this howto.

Package name: sendmail
Service name: sendmail
Port number: 25/110
service sendmail status
netstat atnp |grep 25
netstat atnp |grep 110
Path: /etc/mail/ /etc/mail/
Log file: /var/log/maillog

Editing is not appreciated,as this file is a little bit
buggy and might confuse you, so it would be better idea that you edit and that export the all changes made in
to file by using 'm4' utility. Also as we have seen that lines
in a nix* config file can be commented by placing '#' at the start of a line but the behaviour of file is a little bit different you have to put 'dnl' at the start of the line to comment it.

Now we will do a minimal configuration of sendmail server.

Search out for the word DEAMON_OPTIONS and change the file like this,you
can put the address of your personal smtp server in place of

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

Now search out for the word CLIENT_OPTIONS, you
can put the address of your personal server in place of


Now search out for the word LOCAL_DOMAIN,and uncomment it


Now search out for the word MASQUERADE_AS,and give the your
domain name. Like it my case, I am using as domain name.

uncomment the below given lines so that localhost/localhost.localdomain
can should be MASQUERADED.

By Default relaying is only allowed to localhost you have to enable will be denied you have to enable relying editing the file /etc/mail/access.db but the problem with this file is that it is binary format
so you would not be able to edit this file but you can edit the text version of this file but edit the below file

Give the all domain names onwhich relaying is accepted, Like this:

# local-host-names - include all aliases for your machine here.
Now you have to made changes exported to access.db file, this can be done by generating the binary from the text version of access.db file. Use this command to perform this task.

makemap hash /etc/mail/access.db < /etc/mail/access

Now open the below file and add all the possible names of your mail server. Like this:


# by default we allow relaying from localhost...
192.168.0 RELAY RELAY
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect: RELAY

Configuring IMAP AND POP3:
Configuring IMAP & POP3 under kernel 2.2:
In kernel 2.2 you have to change /etc/inetd.conf file. Just open the /etc/inetd.conf file and search out for imap & pop3 and uncomment the lines which have the keywords pop3 and imap like this:

pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d
imap stream tcp nowait root /usr/sbin/tcpd imapd

Now you have to restart the inetd to make changes work for you, you can do this by issuing this command to restart inetdd

killall -HUP inetd
Configuring IMAP & POP3 under kernel 2.4:
In kernel 2.4 these services run under xinetd. xinetd manages these services you can configure these services under the directory /etc/xinetd.d This directory have different files for imap and pop3 you have to edit these files one by one. By default xinetd disables these services, you have to simply enable these services to do this just change disable =yes
to disable = no like this:

[root@pc1 ~]# vi /etc/xinetd.d/ipop3
# default: off
# description: The POP3 service allows remote users to access their mail \
# using an POP3 client such as Netscape Communicator, mutt, \
# or fetchmail.
service pop3
disable = no
socket_type = stream
wait = no
user = root
server = /usr/sbin/ipop3d
log_on_success += HOST DURATION
log_on_failure += HOST

Similarly you can change the imap file like this:

[root@pc1 ~]#vi /etc/xinetd.d/imap
# default: off
# description:The IMAP service allows remote users to access their mail using\
# an IMAP client such as Mutt, Pine, fetchmail, or Netscape \
# Communicator.
service imap
disable = no
socket_type = stream
wait = no
user = root
server = /usr/sbin/imapd
log_on_success += HOST DURATION
log_on_failure += HOST

Now make your changes work for you, you have to restart xinetdd by issuing this command

[root@pc1 ~]service xinetd restart

Configuring POP3 under kernel 2.6:
In kernel 2.6 pop3 servic runs under dovecot under /etc/dovecot.conf, you just have to made a little change just uncomment these lines like this:
protocol pop3 {
listen = [::]

Now restart the dovecot service to make changes work for you like this:

root@pc1 ~]service dovecot restart

Client side configurations:
To configure a Microshit(ooh i was assumed to say microsoft) client open any email program, usually people use outlook. So just open outlook
and go to

Tools >>> accounts>>>add>>mail>>>

give display name any name you want others to call you.Click next and select pop3 from above drop down menu now give address of incoming mail server, you can give the IP of the mail server like in my case. But if the DNS is configured properly than you can use FQDN(fully qualified domain name). Like in my case

Click next and give the Username and password for your account click finish.
Here one thing should be remember that outgoing mail server(smtp) uses 25 port while incoming mail server(pop3) uses 110 port.

Testing basic connectivity:
You can use the telnet command to test the basic connectivity like this:

[root@pc1 ~]# telnet 25
Connected to (
Escape character is '^]'.
220 ESMTP Sendmail 8.13.8/8.13.8; Sun, 22 Mar 2009 18:14:19 +0500

[root@pc1 ~]# telnet 110
Connected to (
Escape character is '^]'.
+OK Dovecot ready.

Posted: Sun Apr 12, 2009 10:56 am
by Muhammad Saad
I think it will be helpful if you use code tags to clear the difference between your instructions and code. :roll: