Install SquirrelMail on CentOS 7

Tool ที่ใช้ในการสร้าง Mail Server บน Linux ก็มีอยู่หลายตัวด้วยกัน แต่เราจะมาติดตั้ง SquirrelMail ซึ่งมีมานานแล้ว เป็นหนึ่งใน Open Source ที่คนไทยนิยมใช้กันมานานมาก


Component

  • Postfix : ใช้ในการส่งอีเมล์
  • Dovecot : ใช้ในการรับอีเมล์
  • SquirrelMail : เป็น Web Interface สำหรับผู้ใช้งาน

Install

  • ทำการ Update และ Upgrade
# yum update && yum upgrade -y
  • ติดตั้ง Telnet
# yum install telnet -y
  • ติดตั้ง Postfix
# yum install postfix -y
  • แก้ไขไฟล์ Configuration Postfix
# vi /etc/postfix/main.cf
myhostname = lab-mx.lab.local
mydomain = lab.local
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 192.168.1.0/24, 127.0.0.0/8
home_mailbox = Maildir/
  • สั่ง Start Service
# systemctl start postfix
  • สร้าง User
# useradd user1
# passwd user1
# useradd user2
# passwd user2
  • ทดสอบการติดตั้ง Postfix โดยการส่งอีเมล์ไปยัง User lablocal
# telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 lab-mx.lab.local ESMTP Postfix
ehlo localhost
250-lab-mx.lab.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 .
message
.
250 2.0.0 Ok: queued as 854FE405245A
quit
221 2.0.0 Bye
Connection closed by foreign host.
  •  ตรวจสอบอีเมล์ที่ส่งไปยัง user1
# cd /home/user1/Maildir/new/
# ls -lrt
total 4
-rw-------. 1 user1 user1 374 Jul 11 16:36 1531301813.Vfd00I60bc2cdM968518.lab-mx.lab.local
# cat 1531301813.Vfd00I60bc2cdM968518.lab-mx.lab.local
Return-Path: <user1@lab.local>
X-Original-To: user1
Delivered-To: user1@lab.local
Received: from localhost (localhost [IPv6:::1])
        by lab-mx.lab.local (Postfix) with ESMTP id 854FE405245A
        for ; Wed, 11 Jul 2018 16:36:40 +0700 (+07)
Message-Id: <20180711093644.854FE405245A@lab-mx.lab.local>
Date: Wed, 11 Jul 2018 16:36:40 +0700 (+07)
From: user1@lab.local

message
  • ติดตั้ง Dovecot
# yum install dovecot -y
  • แก้ไขไฟล์ Configuration Dovecot ( 1 )
# vi /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp
  • แก้ไขไฟล์ Configuration Dovecot ( 2 )
# vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
  • แก้ไขไฟล์ Configuration Dovecot ( 3 )
# vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login
  • แก้ไขไฟล์ Configuration Dovecot ( 4 )
# vi /etc/dovecot/conf.d/10-master.conf
unix_listener auth-userdb {
 #mode = 0600
 user = postfix 
 group = postfix
  • สั่ง Start Service
# systemctl start dovecot
  • ทดสอบการติดตั้ง Dovecot โดยการอ่านอีเมล์ที่ส่งไปยัง user1
# telnet localhost pop3
Trying ::1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user user1
+OK
pass password1
+OK Logged in.
list
+OK 1 messages:
1 385
.
retr 1
+OK 385 octets
Return-Path: <user1@lab.local>
X-Original-To: user1
Delivered-To: user1@lab.local
Received: from localhost (localhost [IPv6:::1])
        by lab-mx.lab.local (Postfix) with ESMTP id 854FE405245A
        for ; Wed, 11 Jul 2018 16:36:40 +0700 (+07)
Message-Id: <20180711093644.854FE405245A@lab-mx.lab.local>
Date: Wed, 11 Jul 2018 16:36:40 +0700 (+07)
From: user1@lab.local

message
.
quit
+OK Logging out.
Connection closed by foreign host.
  • ติดตั้ง httpd, PHP, MySQL สำหรับ Roundcubemail
# yum install httpd php php-common php-json php-xml php-mbstring php-imap php-pear-DB php-mysql mysql mysql-server -y
  • ติดตั้ง SquirrelMail
# wget -4 http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm 
# yum install squirrelmail -y
# systemctl start httpd
  •  ตั้งค่า SquirrelMail
# cd /usr/share/squirrelmail/config/
# ./conf.pl
  • เลือกเมนู Server Settings
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
  •  ตั้งค่าเสร็จแล้วอย่าลืม Save
SquirrelMail Configuration : Read: config.php (1.4.0)
---------------------------------------------------------
Server Settings

General
-------
1.  Domain                 : lab-mx.lab.local
2.  Invert Time            : false
3.  Sendmail or SMTP       : SMTP

A.  Update IMAP Settings   : localhost:143 (cyrus)
B.  Update SMTP Settings   : localhost:25

R   Return to Main Menu
C   Turn color off
S   Save data
Q   Quit

Command >>
  • ทำการ Restart Service httpd
# systemctl restart httpd
  • เข้าไปที่หน้าเว็บ http://localhost/webmail แล้วกรอก Username และ Password ของ user1 ที่เราสร้าง
  • ทดสอบส่งอีเมล์ไปยัง user2
  • ตรวจสอบอีเมล์ของ user2

อ่านเพิ่มเติม : https://bit.ly/2KPrHffhttps://red.ht/2L3dpH3https://bit.ly/2Jk6Wmfhttps://bit.ly/2rRvm10, https://bit.ly/2mf4h46


Leave a Reply

Your email address will not be published. Required fields are marked *