Extmail郵件服務器centos搭建(一)

原文地址:https://www.aolens.cn/?p=1018


1,Extmail概述

ExtMail Solution 是一個基於優秀開源軟件的電子郵件系統解決方案,核心部件包括了Postfix、Amavisd-new、ClamAV、ExtMail、ExtMan、Courier系列軟件。是一個功能相對比較齊全的免費電子郵件系統。html

而其中Extmail 是一個以perl語言編寫,面向大容量/ISP級應用,免費的高性能Webmail軟件,主要包括ExtMail、Extman兩個部分的程序套件。ExtMail套件用於提供從瀏覽器中登陸、使用郵件系統的Web操做界面,而Extman套件用於提供從瀏覽器中管理郵件系統的Web操做界面。node

2,Extmail工做原理

Extmail的核心部分是postfix,是一種web頁面,能夠建立帳號,能夠收發郵件。extman能夠帳號註冊。帳號存放在mysql裏面。postfix發信件,dovecot收信件。利用outlook收信件(docecot)和發信件(postfix)都要經過mysql查詢。發信件(postfix)要提取mysql帳號信息要經過courier-authlib。是基於虛擬賬號的郵件系統。mysql

配置準備:web

修改主機名爲mail.aolens.cnsql

在DNS上解析mail.aolens.cn數據庫

  • @ MX mail.aolens.cnvim

  • mail A ip地址centos

3,Extmail搭建瀏覽器

3.1 安裝依賴安全

[root@node2 ~]# yum install httpd mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect
 
[root@node2 ~]# yum groupinstall "Development Libraries」 「Development Tools"
 
root@node2 ~]# service httpd start
 
正在啓動 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using node2.aolens.cn for ServerName
 
[肯定]
 
[root@node2 ~]# service mysqld start
 
初始化 MySQL 數據庫: Installing MySQL system tables...
 
[肯定]
正在啓動 mysqld:                                          [肯定]
 
[root@node2 ~]# mysqladmin password aolens    #爲數據庫設置密碼
3.2 安裝postfix
 
[root@node2 ~]# rpm -qa postfix
 
postfix-2.6.6-2.2.el6_1.x86_64
 
[root@node2 ~]# rpm -e postfix --nodeps
 
[root@node2 ~]# id postfix
uid=89(postfix) gid=89(postfix) 組=89(postfix),12(mail)
 
[root@node2 ~]# userdel postfix
 
[root@node2 ~]# groupdel postfix
 
[root@node2 ~]# grep postfix /etc/passwd
 
[root@node2 ~]# rm -rf /var/spool/postfix
 
[root@node2 ~]# groupadd -g 2525 postfix
 
[root@node2 ~]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
 
[root@node2 ~]# groupdel postdrop
 
[root@node2 ~]# groupadd -g 2526 postdrop
[root@node2 ~]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
 
[root@node2 ~]# grep post* /etc/passwd
 
postfix:x:2525:2525::/home/postfix:/sbin/nologin
 
postdrop:x:2526:2526::/home/postdrop:/sbin/nologin

postfix版本:postfix-3.2-20160327

[root@node2 ~]# wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/experimental/postfix-3.2-20160327.tar.gz
 
[root@node2 ~/postfix-3.2-20160327]# yum install cyrus-sasl*
 
SASL:Simple Authintication Secure Layer簡單認證安全層,用來認證郵箱帳號的
 
[root@node2 ~/postfix-3.2-20160327]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto’
 
[root@node2 ~/postfix-3.2-20160327]# make && make install && echo ok
 
按照如下提示輸入相關路徑,省略表示採用默認值
 
install_root: [/] /
tempdir: [/root/postfix-3.2-20160327] /tmp
config_directory: [/etc/postfix] /etc/postfix
command_directory: [/usr/sbin] /usr/sbin
daemon_directory: [/usr/libexec/postfix]
data_directory: [/var/lib/postfix]
html_directory: [no] /var/www/postfix_html
mail_owner: [postfix]
mailq_path: [/usr/bin/mailq]
manpage_directory: [/usr/local/man]
queue_directory: [/var/spool/postfix]
readme_directory: [no]
sendmail_path: [/usr/sbin/sendmail]
setgid_group: [postdrop]
shlib_directory: [no]
meta_directory: [/etc/postfix]
[root@node2 ~/postfix-3.2-20160327]# newaliases
 
newaliases: warning: smtputf8_enable is true, but EAI support is not compiled in
 
postalias: warning: smtputf8_enable is true, but EAI support is not compiled in
 
[root@node2 /media]# mkdir postfix2.6
 
[root@node2 /media]# cd postfix2.6/
 
[root@node2 /media/postfix2.6]# wget http://mirrors.sohu.com/centos/6.7/os/x86_64/Packages/postfix-2.6.6-6.el6_5.x86_64.rpm
 
[root@node2 /media/postfix2.6]# rpm2cpio postfix-2.6.6-6.el6_5.x86_64.rpm |cpio -id
 
19862 塊
 
[root@node2 /media/postfix2.6]# ls *
 
postfix-2.6.6-6.el6_5.x86_64.rpm
 
etc:
 
pam.d  postfix  rc.d  sasl2
 
usr:
 
bin  lib  libexec  sbin  share
 
var:
 
lib  spool

#建立sysv腳本

[root@node2 /media/postfix2.6/etc/rc.d/init.d]# cp -p postfix /etc/init.d/
 
[root@node2 ~]# chown -R postfix /var/lib/postfix
 
[root@node2 ~]# service postfix start
 
啓動 postfix:                                             [肯定]
 
[root@node2 ~]# ss -tnlp|grep 25
LISTEN     0      100                       *:25                       *:*      users:(("master",55347,13))
 
[root@node2 ~]# chkconfig --add postfix
 
[root@node2 ~]# chkconfig postfix on
 
[root@node2 ~]# vim /etc/postfix/main.cf
 
#添加下列參數
 
myhostname = mail.aolens.cn
 
mydomain = aolens.cn
myorigin = aolens.cn    #郵件地址假裝假裝mail.aolens.cn爲aolens.cn
 
inet_interfaces = all
 
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain       #全部目標郵件爲以上的就是本機,不用中繼了
 
mynetworks = 192.168.1.0/24,127.0.0.0/8

##這裏注意一下,我192.168.1.0/24開始的時候寫成192.168.1.129/24 致使rcpt to:.. 一直453錯誤。

使用如下命令驗正postfix是否支持cyrus風格的sasl認證,若是您的輸出爲如下結果,則是支持的:

[root@mail ~]# service saslauthd start
 
正在啓動 saslauthd:                                       [肯定]
 
[root@mail ~]# postconf -a
 
cyrus
 
dovecot

postconf命令:配置postfix

  • -d:顯示默認的配置

  • -n:顯示修改的配置

  • -m:顯示全部所支持的查找表類型

  • -a:顯示支持的SASL客戶端插件類型

  • -e:PARMATER=VALUE:更改某參數配置信息,並保存至main.cf文件中

smtp狀態碼:

  • 1XX:

  • 2XX:正確信息

  • 3XX:當前信息沒有結束

  • 4XX:暫時性錯誤

  • 5XX:永久性錯誤

smtp:協議命令

  • helo (smtp協議)

  • ehlo (esmtp協議)

  • mail from:    郵件發送人

  • rcpt to: 郵件接收人

  • date 郵件內容

  • Subject: 郵件標題

  • . 郵件結束符

alias:郵件別名

abc@abc.com:efg@efg.com   法網abc的其實會發到efg

使用newaliases來生成/etc/aliases.db

驗證postfix是否安裝OK

[root@mail ~]# useradd test
 
[root@mail ~]# telnet localhost 25
 
Trying ::1...
 
telnet: connect to address ::1: Connection refused
 
Trying 127.0.0.1...
 
Connected to localhost.
 
Escape character is '^]'.
 
220 Welcome to our mail.aolens.cn ESMTP,Warning: Version not Available!
 
helo
 
501 Syntax: HELO hostname
 
helo localhost
 
250 mail.aolens.cn
 
mail from:aolens@aolens.cn
 
250 2.1.0 Ok
 
rcpt to:test
 
250 2.1.5 Ok
 
data
 
354 End data with <CR><LF>.<CR><LF>
 
Subject:aaa
 
aaaaaaa
 
.
 
250 2.0.0 Ok: queued as 2B78580CCB
 
quit
 
221 2.0.0 Bye
 
Connection closed by foreign host.
 
[root@mail ~]# vim /var/spool/mail/test
 
From aolens@aolens.cn  Wed May 11 10:24:45 2016
 
Return-Path: <aolens@aolens.cn>
 
X-Original-To: test
 
Delivered-To: test@mail.aolens.cn
 
Received: from localhost (localhost [127.0.0.1])
 
by mail.aolens.cn (Postfix) with SMTP id 2B78580CCB
 
for <test>; Wed, 11 May 2016 10:24:25 +0800 (CST)
 
Subject:aaa
 
Message-Id: <20160511022433.2B78580CCB@mail.aolens.cn>
 
Date: Wed, 11 May 2016 10:24:25 +0800 (CST)
 
From: aolens@aolens.cn
 
aaaaaaa

咱們發如今郵件投遞目錄裏對應的用戶中有咱們發送過來的郵件。這就說明發送成功了

相關文章
相關標籤/搜索