Linux Administrator (Advance) Mr.Kriangsak Namkot Trainer & Director Jodoi IT&Service Co.,Ltd. jodoi@jodoi.com jodoi1819@hotmail.com http://www.jodoi.com Linux Admin II Day 2 9:00 น. -12.00 น. - Mail Server (postfix,dovicot ) 10:30 น. -10.45 น. - Coffee Break 10.45 น. -12.00 น. - Mail Server (postfix,dovicot ) 12.00 น. -13.00 น. - Lunch 13.00 น. -14.30 น. - Webmail (Squirrelmail ) 14.30 น. -14.45 น. - Coffee Break 14.45 น. -16.00 น. - DNS Server & Mail Server 1
Mail Server Mail Server - SMTP server SMTP (Simple mail transfer protocol) server is a computer that receives outgoing mail messages from users and routes them to their intended recipients. - POP server POP (Post Office Protocol) mail refers to email software on your personal computer that sends and receives mail via a shared computer's electronic post office. - IMAP Server IMAP (Internet Message Access Protocol) is a protocol for retrieving email messages and working with mailboxes on a mail server using an email client Postfix SMTP Server Postfix Mail Server Remove sendmail [root@jodoi-server html]# /etc/init.d/sendmail stop Shutting down sm-client: [ OK ] Shutting down sendmail: [ OK ] [root@jodoi-server html]# yum remove sendmail Install postfix [root@jodoi-server html]# yum install postfix or [root@jodoi-server ~]# rpm -ivh postfix-2.3.3-2.i386.rpm 2
Postfix Mail Server [root@jodoi-server /]# vi /etc/postfix/main.cf #myhostname = host.domain.tld #myhostname = virtual.domain.tld myhostname = jodoi-server.com #mydomain = domain.tld mydomain = jodoi-server.com #myorigin = $mydomain myorigin = $mydomain Postfix Mail Server #inet_interfaces = all inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost #mynetworks = 168.100.189.0/28, 127.0.0.0/8 mynetworks = 192.168.1.0/24, 127.0.0.0/8 home_mailbox = Maildir/ 3
Postfix Mail Server [root@jodoi-server /]# /etc/init.d/postfix start Starting postfix: [ OK ] [root@jodoi-server html]# netstat -anp grep 25 tcp 0 00.0.0.0:25 0.0.0.0:* LISTEN 5527/master [root@jodoi-server /]# ps -ef grep postfix root 4463 1 016:16? 00:00:00 /libexec/postfix/master postfix 4464 4463 016:16? 00:00:00 pickup -l -t fifo -u postfix 4465 4463 016:16? 00:00:00 qmgr -l -t fifo -u root 4586 2472 016:50 pts/0 00:00:00 grep postfix Postfix Mail Server Testing [root@jodoi-server /]# telnet 192.168.1.200 25 Trying 192.168.1.200... Connected to 192.168.1.200 (192.168.1.200). Escape character is '^]'. helo jodoi-server.com mail from:jodoi@jodoi.com rcpt to:jodoi@jodoi-server.com data test mail. quit 221 2.0.0 Bye Connection closed by foreign host. 4
Postfix Mail Server [root@jodoi-server /]# tail -f /var/log/maillog Aug 14 16:22:32 jodoi-server postfix/qmgr[4465]: 315E927BD1: removed Aug 14 16:51:47 jodoi-server postfix/smtpd[4590]: connect from unknown[192.168.1.200] Aug 14 16:52:23 jodoi-server postfix/smtpd[4590]: 84A7927BC7: client=unknown[192.168.1.200] Aug 14 16:52:35 jodoi-server postfix/cleanup[4595]: 84A7927BC7: message-id=<20080814095223.84a7927bc7@jodoi-server.com> Aug 14 16:52:35 jodoi-server postfix/qmgr[4465]: 84A7927BC7: from=<jodoi@jodoi.com>, size=354, nrcpt=1 (queue active) Aug 14 16:52:35 jodoi-server postfix/local[4596]: 84A7927BC7: to=<jodoi@jodoi-server.com>, relay=local, delay=23, delays=22/0.07/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox) Aug 14 16:52:35 jodoi-server postfix/qmgr[4465]: 84A7927BC7: removed Aug 14 16:52:39 jodoi-server postfix/smtpd[4590]: disconnect from unknown[192.168.1.200] Dovecot POP3/IMAP Server [root@jodoi-server ~]# rpm -q dovecot dovecot-1.0-1.2.rc15.el5 [root@jodoi-server html]# yum install dovecot or [root@jodoi-server ~]# rpm -ivh dovecot-1.0.7-2.el5.i386.rpm [root@jodoi-server /]# vi /etc/dovecot.conf #protocols = imap imaps pop3 pop3s protocols = imap pop3 # mail_location = mbox:~/mail:inbox=/var/mail/%u 5
Dovecot POP3/IMAP Server [root@jodoi-server /]# /etc/init.d/dovecot start Starting Dovecot Imap: [ OK ] [root@jodoi-server /]# netstat -anp grep dovecot tcp 0 0:::110 :::* LISTEN 4746/dovecot tcp 0 0:::143 :::* LISTEN 4746/dovecot Dovecot POP3/IMAP Server [root@jodoi-server /]# telnet 192.168.1.200 110 Trying 192.168.1.200... Connected to 192.168.1.200 (192.168.1.200). Escape character is '^]'. +OK Dovecot ready. user jodoi +OK pass xxxxx +OK Logged in. list +OK 18 messages: 1 1439 2 3250 quit +OK Logging out. Connection closed by foreign host. 6
Mail Server Squirrelmail Web Mail Squirrelmail http://www.squirrelmail.org/download.php [root@jodoi-server ~]# wget http://voxel.dl.sourceforge.net/sourceforge/squirrelmail/ squirrelmail-1.4.15.tar.gz [root@jodoi-server ~]# tar -zxvf squirrelmail-1.4.15.tar.gz [root@jodoi-server ~]# mv squirrelmail-1.4.15 squirrelmail [root@jodoi-server squirrelmail]# pwd /var/www/html/squirrelmail 7
Squirrelmail Web Mail [root@jodoi-server config]# pwd /var/www/html/squirrelmail/config [root@jodoi-server config]# rm -f config.php [root@jodoi-server config]#./conf.pl config 3 Menu 1. Organization Preferences 2. Server Settings and 3. General Options Squirrelmail Web Mail 1. Organization Preferences SquirrelMail Configuration : Read: config_default.php (1.4.0) --------------------------------------------------------- Organization Preferences 1. Organization Name : Jodoi Webmail 2. Organization Logo :../images/sm_logo.png 3. Org. Logo Width/Height : (308/111) 4. Organization Title : SquirrelMail $version 8
2. Server Settings Squirrelmail Web Mail SquirrelMail Configuration : Read: config_default.php (1.4.0) --------------------------------------------------------- Server Settings General ------- 1. Domain : jodoi-server.com 2. Invert Time : false 3. Sendmail or SMTP : SMTP A. Update IMAP Settings : localhost:143 (other) B. Update SMTP Settings : localhost:25 3. General Options Squirrelmail Web Mail SquirrelMail Configuration : Read: config.php (1.4.0) --------------------------------------------------------- General Options 1. Data Directory : /var/www/html/squirrelmail/data/ 2. Attachment Directory : /var/www/html/squirrelmail/data/ 3. Directory Hash Level : 0 4. Default Left Size : 150 5. Usernames in Lowercase : false 9
Squirrelmail Web Mail S Save data Q Quit Command >> s Data saved in config.php Press enter to continue... Command >> q [root@jodoi-server config]# chmod -fr 777 /var/www/html/squirrelmail/data/ [root@jodoi-server config]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] Squirrelmail Web Mail Read Thai 10. Languages 2. Default Charset : utf8 10
Squirrelmail Web Mail Squirrelmail Web Mail 11
Squirrelmail Web Mail Mail Server # vi /var/named/zone.jodoi-server.com @ IN A 192.168.1.220 @ IN NS ns1.jodoi-server.com. @ IN MX 10 mail.jodoi-server.com. @ IN MX 20 pop3.jodoi-server.com. @ IN MX 30 smtp.jodoi-server.com. www IN A 192.168.1.220 ns1 IN A 192.168.1.220 mail IN A 192.168.1.220 pop3 IN A 192.168.1.220 smtp IN A 192.168.1.220 12
Mail Server 13