Configuring Sendmail on RHEL5

Share your expert knowledge and show off your skills.
Post Reply
CyberBob
Cadet
Posts: 8
Joined: Wed Mar 12, 2008 11:44 am
Location: End of Road. . . .
Contact:

Configuring Sendmail on RHEL5

Post 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 cyberbob.thedarklord@gmail.com 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/sendmail.mc /etc/mail/sendmail.cf
Log file: /var/log/maillog

Note:
Editing sendmail.cf is not appreciated,as this file is a little bit
buggy and might confuse you, so it would be better idea that you edit sendmail.mc and that export the all changes made in sendmail.mc
to sendmail.cf 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 sendmail.mc 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 192.168.0.1

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

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

CLIENT_OPTIONS(`Family=inet,Address=192.168.0.0')dnl

Now search out for the word LOCAL_DOMAIN,and uncomment it

LOCAL_DOMAIN(`localhost.localdomain')dnl

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

MASQUERADE_AS(`cyberdyne.net')dnl
uncomment the below given lines so that localhost/localhost.localdomain
can should be MASQUERADED.
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl


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

/etc/mail/access
Give the all domain names onwhich relaying is accepted, Like this:

# local-host-names - include all aliases for your machine here.
pc1.cyberdyne.net
cyberdyne.net
localhost
localhost.localdomain
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:

/etc/mail/local-host-names

# by default we allow relaying from localhost...
192.168.0 RELAY
cyberdyne.net RELAY
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 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:
/etc/xinetd.d/ipop3


[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:
vi
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 192.168.0.1 in my case. But if the DNS is configured properly than you can use FQDN(fully qualified domain name). Like in my case
cyberdyne.net

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 cyberdyne.net 25
Trying 192.168.0.1...
Connected to cyberdyne.net (192.168.0.1).
Escape character is '^]'.
220 pc1.cyberdyne.net ESMTP Sendmail 8.13.8/8.13.8; Sun, 22 Mar 2009 18:14:19 +0500


[root@pc1 ~]# telnet cyberdyne.net 110
Trying 192.168.0.1...
Connected to cyberdyne.net (192.168.0.1).
Escape character is '^]'.
+OK Dovecot ready.
Last edited by CyberBob on Fri Apr 17, 2009 9:45 pm, edited 2 times in total.
Muhammad Saad
Battalion Havaldaar Major
Posts: 273
Joined: Sat Jan 27, 2007 11:07 pm
Location: Dera Ismail Khan, Pakistan
Contact:

Post by Muhammad Saad »

I think it will be helpful if you use code tags to clear the difference between your instructions and code. :roll:
Post Reply