Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the internet.
Features:1. Easy migration
a. It is simple and extremely efficient to migrate a mail server installed using sendmail, as compared to giants like Exchange, whose migration requires a lot of steps and might take hours.
2. Simple configuration
a. Sendmail configuration has been made easy with the introduction of its macro file sendmail.mc. All it needs to be done is just a few lines within the macro file and compile it into an actual sendmail configuration file.
Install SendmailSendmail requires 3 packages to work; sendmail, sendmail-cf and m4.
There are 3 ways to install sendmail:
- Installing through Yum
- Install RPM packages
- Build from source
Install through Yum is simple. Just execute the following command to install.
~]# Yum Install sendmail sendmail-cf m4
RPM Package Manager
Installing through RPM Package manager requires a bit more work. Normally we will install from the CD/DVD-ROM provided. If in any case a CD/DVD-ROM is not available, we might have to download the rpm file from online source.
a. Navigate to the source, which most like be the CD/DVD-ROM. The source CD/DVD-ROM have to be inserted first
~]# cd / media/RHEL_5.3\ x86_64\ DVD/Server
b.Install the rpm
~]# rpm –ivh sendmail*
~]# rpm –ivh m4*
Install from source
a.Download the source
~]# wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.14.4.tar.gz
b.Unzip the source
~]# tar –zxv sendmail.8.14.4.tar.gz
c. Compile the source
~]# cd sendmail.8.14.4
# ./Build
# ./Build install
Configure Sendmail
Sendmail is a very huge topic to cover. Yet in this document we will be covering on a simple installating to get sendmail working and the methods to test and troubleshooting sendmail should problem arises.
Dovecot is used in this document to IMAP and POP access to the clients. In this document we will also be covering how clients from both Linux and Windows platform are able to access the mail server.
Ensure DNS is configured properly for Mail Exchange
1.Make sure the fully qualified domain name (fqdn) of the mail server host can be resolved.
~]# host mail.ca.com
mail.ca.com is an alias for svr1.ca.com.
svr1.ca.com has address 192.168.205.10
2.Ensure that the MX record in the DNS zone file is pointed correctly to the IP address of the mail server.
~]# cat /var/named/ca.com.zone
;
; Zone file for my-site.com
;
; The full zone file
;
$TTL 3D
@ IN SOA ns1.ca.com. hostmaster.ca.com. (
200211152 ; serial#
3600 ; refresh, seconds
3600 ; retry, seconds
3600 ; expire, seconds
3600 ) ; minimum, seconds
IN NS ns1.ca.com. ; Inet Address of nameserver
IN MX 10 mail.ca.com. ; Primary Mail Exchangersvr1 IN A 192.168.205.10
mail IN CNAME svr1
Configure sendmail.mc
1. Ensure that sendmail is listening to the correct network
a. Using netstat to determine to network that the server is listening to
Correct result:
~]# netstat -an grep :25 grep tcp
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
Incorrect result:
~]# netstat -an grep :25 grep tcp
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
b.If the server is only listening to localhost, make the following changes by commenting the daemon_options line in sendmail.mc. To comment, just add dnl in front of the line.
~]# vi /etc/mail/sendmail.mc
dnl #
dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
dnl DAEMON_OPTIONS(`Port=smtp, Name=MTA')
2.Comment out SMART_HOST entry, which is only required for client.
dnl define(`SMART_HOST',`mail.ca.com')
3.Regenerate sendmail.cf and start sendmail
~]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
~]# service sendmail restart
Configure DoveCot for POP access
1.Install dovecot if required
~]# rpm –ivh dovecot*
2.Ensure dovecot is configured for pop3
~]# vi /etc/dovecot.conf
# Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
protocols = imap imaps pop3 pop3s
3.Start dovecot
~]# service dovecot start
4.Ensure dovecot is serving by using netstat
~]# netstat -a egrep -i 'popimap'
tcp 0 0 *:imaps *:* LISTEN
tcp 0 0 *:pop3s *:* LISTEN
tcp 0 0 *:pop3 *:* LISTEN
tcp 0 0 *:imap *:* LISTEN
5.There are situation whereby the administrator needs to restrict POP3 access from certain domains. We shall achieve this by using IPTables at the POP3 server to deny the hosts from that domain. The below example demonstrate that all hosts within a domain of subnet 192.168.205.0 network are dropped, and all others will be accepted.
~]# iptables -A INPUT -s 192.168.205.0/24 -p tcp --dport 110 -j DROP
~]# iptables –A INPUT –j ACCEPT
Configure Linux Sendmail Client
1.Install Sendmail onto the client and ensure DNS is working properly
a.Refer to “Install Sendmail” section for installation
b.Ensure that FQDN of the mail server can be resolved.
~]# nslookup mail.ca.com
Server: 192.168.205.10
Address: 192.168.205.10#53
mail.ca.com canonical name = svr1.ca.com.
Name: svr1.ca.com
Address: 192.168.205.10
2.Configure sendmail.mc. Ensure that the option below is configured properly by pointing it to the FQDN of the mail server.
~]# vi /etc/mail/sendmail.mc
define(`SMART_HOST',`mail.ca.com')
3. Regenerate sendmail.cf and start sendmail
~]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
~]# service sendmail restart
Configure Windows Client (Microsoft Outlook 2007)
1.Start MS Outlook 2007. Cancel wizard if prompted.
2.Setup the account.
a.Go to Account setting
b. Add new account
c. Check “Manually configure server settings or additional server type” and click next
d. Select “Internet E-mail” for E-mail service and click next
e.Enter the following information for E-mail settings:
i.User Information:
- Your Name: student
E-mail Address: student@ca.com
- Account Type: POP3
- Incoming mail server: 192.168.205.10
Outgoing mail server: mail.ca.com
- Username: student
- Password: *omitted*
Troubleshooting Sendmail
1.Testing TCP connectivity of Sendmail using telnet
The mail server needs to be accessed by required clients without being blocked by firewalls or other connectivity issues. This step helps to check the remote connectivity from client to the mail server.
a.Telnet to the mail server using port 25. A success response will give you 220 status code, while a fail response will give you time-out or “No route to host” message.
Success:
~]$ telnet mail.ca.com 25Trying 192.168.205.10...
Connected to mail.ca.com (192.168.205.10).
Escape character is '^]'.
220 svr1.ca.com ESMTP Sendmail 8.13.8/8.13.8; Sun, 18 Apr 2010 14:33:24 +0800
Failure:
~]$ telnet mail.ca.com 25
Trying 192.168.205.10...
telnet: connect to address 192.168.205.10: No route to host
telnet: Unable to connect to remote host: No route to host
2.Monitoring sendmail events through /var/log/maillog file. Root access is required to access this file.
~]# tail -f /var/log/maillog
Apr 4 19:12:03 svr1 sendmail[6609]: o34BC2KE006609: to=root, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=31068, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o34BC3ng006611 Message accepted for delivery)
Apr 4 19:12:03 svr1 sendmail[6612]: o34BC3ng006611: to=
No comments:
Post a Comment