標籤:解決方案 郵件伺服器 收發郵件 開源軟體
原文地址:https://www.aolens.cn/?p=10181,Extmail概述
ExtMail Solution 是一個基於優秀開源軟體的電子郵件系統解決方案,核心組件包括了Postfix、Amavisd-new、ClamAV、ExtMail、ExtMan、Courier系列軟體。是一個功能相對比較齊全的免費電子郵件系統。
而其中Extmail 是一個以perl語言編寫,面向大容量/ISP級應用,免費的高效能Webmail軟體,主要包括ExtMail、Extman兩個部分的程式套件。ExtMail套件用於提供從瀏覽器中登入、使用郵件系統的Web操作介面,而Extman套件用於提供從瀏覽器中管理郵件系統的Web操作介面。
2,Extmail工作原理
Extmail的核心部分是postfix,是一種web頁面,可以建立帳號,可以收發郵件。extman可以帳號註冊。帳號存放在mysql裡面。postfix發信件,dovecot收信件。利用outlook收信件(docecot)和發信件(postfix)都要通過mysql查詢。發信件(postfix)要提取mysql帳號資訊要通過courier-authlib。是基於虛擬帳號的郵件系統。
配置準備:
修改主機名稱為mail.aolens.cn
在DNS上解析mail.aolens.cn
@ MX mail.aolens.cn
mail A ip地址
3,Extmail搭建
3.1 安裝依賴
[[email protected] ~]# 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 [[email protected] ~]# yum groupinstall "Development Libraries” “Development Tools" [email protected] ~]# service httpd start 正在啟動 httpd:httpd: Could not reliably determine the server‘s fully qualified domain name, using node2.aolens.cn for ServerName [確定] [[email protected] ~]# service mysqld start 初始化 MySQL 資料庫: Installing MySQL system tables... [確定]正在啟動 mysqld: [確定] [[email protected] ~]# mysqladmin password aolens #為資料庫設定密碼3.2 安裝postfix [[email protected] ~]# rpm -qa postfix postfix-2.6.6-2.2.el6_1.x86_64 [[email protected] ~]# rpm -e postfix --nodeps [[email protected] ~]# id postfixuid=89(postfix) gid=89(postfix) 組=89(postfix),12(mail) [[email protected] ~]# userdel postfix [[email protected] ~]# groupdel postfix [[email protected] ~]# grep postfix /etc/passwd [[email protected] ~]# rm -rf /var/spool/postfix [[email protected] ~]# groupadd -g 2525 postfix [[email protected] ~]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix [[email protected] ~]# groupdel postdrop [[email protected] ~]# groupadd -g 2526 postdrop[[email protected] ~]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop [[email protected] ~]# 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
[[email protected] ~]# wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/experimental/postfix-3.2-20160327.tar.gz [[email protected] ~/postfix-3.2-20160327]# yum install cyrus-sasl* SASL:Simple Authintication Secure Layer簡單認證安全層,用來認證郵箱帳號的 [[email protected] ~/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’ [[email protected] ~/postfix-3.2-20160327]# make && make install && echo ok 按照以下提示輸入相關路徑,省略表示採用預設值 install_root: [/] /tempdir: [/root/postfix-3.2-20160327] /tmpconfig_directory: [/etc/postfix] /etc/postfixcommand_directory: [/usr/sbin] /usr/sbindaemon_directory: [/usr/libexec/postfix]data_directory: [/var/lib/postfix]html_directory: [no] /var/www/postfix_htmlmail_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][[email protected] ~/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 [[email protected] /media]# mkdir postfix2.6 [[email protected] /media]# cd postfix2.6/ [[email protected] /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 [[email protected] /media/postfix2.6]# rpm2cpio postfix-2.6.6-6.el6_5.x86_64.rpm |cpio -id 19862 塊 [[email protected] /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指令碼
[[email protected] /media/postfix2.6/etc/rc.d/init.d]# cp -p postfix /etc/init.d/ [[email protected] ~]# chown -R postfix /var/lib/postfix [[email protected] ~]# service postfix start 啟動 postfix: [確定] [[email protected] ~]# ss -tnlp|grep 25LISTEN 0 100 *:25 *:* users:(("master",55347,13)) [[email protected] ~]# chkconfig --add postfix [[email protected] ~]# chkconfig postfix on [[email protected] ~]# vim /etc/postfix/main.cf #添加下列參數 myhostname = mail.aolens.cn mydomain = aolens.cnmyorigin = 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認證,如果您的輸出為以下結果,則是支援的:
[[email protected] ~]# service saslauthd start 正在啟動 saslauthd: [確定] [[email protected] ~]# postconf -a cyrus dovecot
postconf命令:配置postfix
smtp狀態代碼:
1XX:
2XX:正確資訊
3XX:當前資訊沒有結束
4XX:暫時性錯誤
5XX:永久性錯誤
smtp:協議命令
helo (smtp協議)
ehlo (esmtp協議)
mail from: 郵件發送人
rcpt to: 郵件接收人
date 郵件內容
Subject: 郵件標題
. 郵件結束符
alias:郵件暱稱
[email protected]:[email protected] 法網abc的其實會發到efg
使用newaliases來產生/etc/aliases.db
驗證postfix是否安裝OK
[[email protected] ~]# useradd test [[email protected] ~]# 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:[email protected] 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. [[email protected] ~]# vim /var/spool/mail/test From [email protected] Wed May 11 10:24:45 2016 Return-Path: <[email protected]> X-Original-To: test Delivered-To: [email protected] 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: <[email protected]> Date: Wed, 11 May 2016 10:24:25 +0800 (CST) From: [email protected] aaaaaaa
我們發現在郵件投遞目錄裡對應的使用者中有我們發送過來的郵件。這就說明發送成功了
本文出自 “aolens·程超” 部落格,請務必保留此出處http://aolens.blog.51cto.com/7021142/1783870
Extmail郵件伺服器centos搭建(一)