องค์ประกอบโปรแกรมของ Mail Server
1. Postfix คือ โปรแกรมในส่วนของการส่งอีเมล์ (Send Email)
2. Dovecot คือ โปรแกรมในส่วนของการรับอีเมล์ (Receive Email)
3. SquirrelMail คือ โปรแกรมในรูปแบบของ เว็บไซต์ เพื่อจัดการอีเมล์บนโปรแกรมเว็บเบราว์เซอร์ (Web based access)
รายละเอียดของ Server
1. IP Address 192.168.1.39
2. Hostname mail.demo.local
3. Linux CentOS 6 32bit
4. Domain demo.local
วิธีการติดตั้ง Mail Server (Postfix, Dovecot, SquirrelMail) บน Linux CentOS
1. กำหนด IP Address แบบ Static IP Address
วิธีตั้งค่า Static IP Address บน CentOS (Linux)
2. ปิดการทำงาน selinux
1
2
3
4
| vi /etc/selinux/config# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values: |
3. ปิด Firewall (ปิดเพื่อการทดสอบเท่านั้น)
1
2
3
4
| service iptables stopservice ip6tables stopchkconfig iptables offchkconfig ip6tables off |
4. ลบโปรแกรม sendmail ออก
1
| yum remove sendmail |
5. Restart เครื่อง
1
| reboot |
6. แก้ไข Hostname
1
2
| vi /etc/sysconfig/networkhostname=mail.demo.local |
7. ติตตั้งโปรแกรม postfix
1
| yum install postfix -y |
8. Config โปรแกรม postfix
1
2
3
4
5
6
7
8
| vi /etc/postfix/main.cfmyhostname = mail.demo.localmydomain = demo.localmyorigin = $mydomaininet_interfaces = allmydestination = $myhostname, localhost.$mydomain, localhost, $mydomainmynetworks = 192.168.1.0/24, 127.0.0.0/8home_mailbox = Maildir/ |
9. Start Service postfix
1
2
| service postfix startchkconfig postfix on |
10. ติดตั้งโปรแกรม telnet
1
| yum install telnet -y |
11. สร้าง User ใหม่ 2 User คือ user1 และ user2
1
2
3
4
5
| useradd user1passwd user1....................useradd user2passwd user2 |
12. ทดสอบการติดตั้ง postfix (ตัวสีแดงคือให้กรอกลงไป)
1
| telnet localhost smtp |
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.demo.local ESMTP Postfix
ehlo localhost
250-mail.demo.local
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:<user1>
250 2.1.0 Ok
rcpt to:<user1>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
message
.
250 2.0.0 Ok: queued as 57DBF7D9A
quit
221 2.0.0 Bye
Connection closed by foreign host.
ทดสอบหลังการส่งอีเมล์จะต้องพบไฟล์การส่งอีเมล์แล้วสามารถเรียกขึ้นมาอ่านได้
(ชื่อของไฟล์ขอให้อ้างอิงในเครื่องของผู้อ่าน เพราะจะไม่มีเหมือนกัน)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| cd /home/user1/Maildir/new/ls1377361942.Vfd00I60158M571583.mail.demo.localcat 1377361942.Vfd00I60158M571583.mail.demo.localReturn-Path: >user1@demo.local<X-Original-To: user1Delivered-To: user1@demo.localReceived: from localhost (localhost.localdomain [127.0.0.1]) by mail.demo.local (Postfix) with ESMTP id 07862993B for >user1<; Sat, 24 Aug 2013 23:32:06 +0700 (ICT)Message-Id: >20130824163217.07862993B@mail.demo.local<Date: Sat, 24 Aug 2013 23:32:06 +0700 (ICT)From: user1@demo.localTo: undisclosed-recipients: |
13. ติดตั้งโปรแกรม dovecot
1
| yum install dovecot -y |
14. Config โปรแกรม dovecot ไฟล์ที่ 1
1
2
| vi /etc/dovecot/dovecot.confprotocols = imap pop3 lmtp |
15. Config โปรแกรม dovecot ไฟล์ที่ 2
1
2
| vi /etc/dovecot/conf.d/10-mail.confmail_location = maildir:~/Maildir |
16. Config โปรแกรม dovecot ไฟล์ที่ 3
1
2
3
| vi /etc/dovecot/conf.d/10-auth.confdisable_plaintext_auth = noauth_mechanisms = plain login |
17. Config โปรแกรม dovecot ไฟล์ที่ 4
1
2
3
4
5
| vi /etc/dovecot/conf.d/10-master.confunix_listener auth-userdb { #mode = 0600 user = postfix group = postfix |
18. Start service dovecot
1
2
| service dovecot startchkconfig dovecot on |
19. ทดสอบการติดตั้งโปรแกรม dovecot (ให้พิมพ์แล้วกด Enter ตัวสีแดง) โดยจะต้องสามารถอ่านอีเมล์ที่พึ่งส่งไปได้
1
| # telnet localhost pop3 |
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user user1
+OK
pass user1
+OK Logged in.
list
+OK 1 messages:
1 420
.
retr 1
+OK 420 octets
Return-Path: <user1@demo.local>
X-Original-To: user1
Delivered-To: user1@demo.local
Received: from localhost (localhost.localdomain [127.0.0.1])
by mail.demo.local (Postfix) with ESMTP id 07862993B
for <user1>; Sat, 24 Aug 2013 23:32:06 +0700 (ICT)
Message-Id: <20130824163217.07862993B@mail.demo.local>
Date: Sat, 24 Aug 2013 23:32:06 +0700 (ICT)
From: user1@demo.local
To: undisclosed-recipients:;
test
.
quit
+OK Logging out.
Connection closed by foreign host.
20. ติดตั้งโปรแกรม httpd, php, mysql และอื่น ๆ (ติดตั้ง php, mysql เอาไว้ก่อนเพื่อนำไปใช้ในส่วนของการติดตั้ง roundcubemail)
1
| yum install httpd php php-common php-json php-xml php-mbstring php-imap php-pear-DB php-mysql mysql mysql-server |
21. ติดตั้งโปรแกรม squirrelmail
1
2
3
4
5
| wget -4 http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpmrpm -ivh epel-release-6-8.noarch.rpm yum install squirrelmailservice httpd startchkconfig httpd on |
22. Config โปรแกรม squirrelmail
1
2
| cd /usr/share/squirrelmail/config/./conf.pl |
23. พิมพ์หมายเลข 2 แล้วกด Enter
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Main Menu --
1. Organization Preferences
2. Server Settings
3. Folder Defaults
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages
D. Set pre-defined settings for specific IMAP servers
C Turn color off
S Save data
Q Quit
Command >> 2
24. แก้ไขค่าต่าง ๆ (เฉพาะในจุดที่เป็นสีแดง) แก้่ไขโดยการพิมพ์หมายเลขหน้าข้อมูลที่ต้องการแก้ไข
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings
General
-------
1. Domain : demo.local
2. Invert Time : false
3. Sendmail or SMTP : SMTP
A. Update IMAP Settings : localhost:143 (uw)
B. Update SMTP Settings : localhost:25
R Return to Main Menu
C Turn color off
S Save data
Q Quit
Command >>
25. แก้ไขครบหมดแล้วให้พิมพ์ S แล้วกด Enter 2 ครั้ง จากนั้นพิมพ์ Q แล้วกด Enter เพื่อออกจากการ Config
26. เพิ่มข้อมูลเข้าไปในไฟล์ โดยให้ใส่เข้าไปที่บรรทัดสุดท้ายของไฟล์
1
2
3
4
5
6
7
8
9
10
| vi /etc/httpd/conf/httpd.confAlias /squirrelmail /usr/share/squirrelmail<Directory /usr/share/squirrelmail> Options Indexes FollowSymLinks RewriteEngine On AllowOverride All DirectoryIndex index.php Order allow,deny Allow from all</Directory> |
27. Restart httpd
1
| service httpd restart |
32. หากต้องการติดตั้ง RoundCube Webmail




