linux下搭建iredmail郵件伺服器

來源:互聯網
上載者:User

標籤:linux   centos   iredmail   郵件伺服器   

iRedMail是一個開源、免費的郵件伺服器項目,基於GPL(v2)協議發布。官網 www.iredmail.org (國內不能訪問),可以通過www.iredmail.com訪問。

iRedMail是一個不錯的郵局伺服器免費解決方案,適合小型企業、個人或者團隊等搭建內部員工郵箱服務;

使用iRedmail搭建郵件伺服器,需要有公網的centos主機。推薦使用vps;


iRedMail 核心組件及其對應的功能:

Postfix: SMTP 伺服器

Dovecot: POP3/IMAP/Managesieve 伺服器

Apache: Web 服務器

MySQL: 用於儲存其它程式的資料,也可用於儲存郵件帳號。

OpenLDAP: 用於儲存郵件帳號。

Policyd: Postfix policy server

Amavisd: 提供 DKIM 簽名及校正、SPF校正、為外發郵件添加“免責聲明”內容,並調用 SpamAssassin 做基於郵件內容的發垃圾掃描,調用 ClamAV 做郵件病毒掃描。

Roundcube: 網頁郵箱;

Awstats: 用於分析 Apache 和 Postfix 記錄檔,並產生簡單的圖表。

Fail2ban: 掃描各種記錄檔,發現多次密碼錯誤等情況時可自動封鎖對方 IP 一段時間。用於保證伺服器安全。

iRedAdmin:基於 web 的郵件帳號管理程式。


1、iredmail安裝

前期準備工作,需要申請獨立的網域名稱,可以到萬網或新網購買網域名稱;

併購買vps,安裝centos系統,有獨立的ip地址;本次類比使用huangxiaofan.com網域名稱;


具體步驟如下:

hostname  mail.huangxiaofan.com

vim /etc/hosts    //加入

127.0.0.1  mail.huangxiaofan.com


配置DNS解析,在網域名稱購買的後台設定:

MX記錄  mail.huangxiaofan.com

A 記錄  把mail.huangxiaofan.com 指向一個vps的IP,這個IP就是我們要做郵件伺服器的ip

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

下載iRedMail

wget http://www.iredmail.com/iRedMail-0.9.1.tar.bz2  

(當前最新版本為0.9.1,以後會變,請到http://www.iredmail.com/download.html 下載最新版本)

若你的伺服器為國內伺服器,那麼在安裝前需要做一些處理:

tar jxvf iRedMail-0.9.1.tar.bz2

cd iRedMail-0.9.1/pkgs

vi  get_all.sh //  把   https://mirrors.fedoraproject.org 改為 http://mirrors.fedoraproject.org

sed -i ‘s/iredmail.org/106.187.51.47/g‘  get_all.sh

cd ..


美國的vps不需要做上面的操作,直接sh執行指令碼;

sh iRedMail.sh


執行後需要下載安裝包,完成後進入到圖形化安裝介面

社區論壇地址,和管理員FAQ文檔地址;選擇yes

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/6D/DD/wKiom1Vtf8KxY-SYAAIKmtBf49A468.jpg" style="float:none;" title="mail1.jpg" alt="wKiom1Vtf8KxY-SYAAIKmtBf49A468.jpg" />

預設郵件儲存目錄/var/vmail,選擇next;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6D/D9/wKioL1VtgWGBl1kcAAH35lKpCv8853.jpg" title="mail2.jpg" style="float:none;" alt="wKioL1VtgWGBl1kcAAH35lKpCv8853.jpg" />

選擇web伺服器,空格鍵選擇apache

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/6D/D9/wKioL1VtgWbyBozUAAEl4aOByV4935.jpg" title="mail3.jpg" style="float:none;" alt="wKioL1VtgWbyBozUAAEl4aOByV4935.jpg" />

選擇後端資料庫儲存郵件帳號,選擇mysql

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/6D/DD/wKiom1Vtf9PjWROPAAKgionnGmw647.jpg" title="mail4.jpg" style="float:none;" alt="wKiom1Vtf9PjWROPAAKgionnGmw647.jpg" />

給mysql管理員root設定密碼,不可為空不能有特殊字元;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6D/DD/wKiom1Vtf9eT8sqZAAF1hnqFZT8438.jpg" title="mail5.jpg" style="float:none;" alt="wKiom1Vtf9eT8sqZAAF1hnqFZT8438.jpg" />

虛擬網域名稱,不能和主機名稱一樣;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6D/D9/wKioL1VtgXWzKAuFAAFW5-GJTDw713.jpg" title="mail6.jpg" style="float:none;" alt="wKioL1VtgXWzKAuFAAFW5-GJTDw713.jpg" />

設定網域名稱管理員密碼,用來管理後台;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/6D/D9/wKioL1VtgXrxhgjuAAHaNluzlK0887.jpg" title="mail7.jpg" style="float:none;" alt="wKioL1VtgXrxhgjuAAHaNluzlK0887.jpg" />

安裝組件

DKIM,電子郵件驗證標準——網域名稱金鑰指定郵件標準。DomainKeys Identified Mail的縮寫;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/6D/DD/wKiom1Vtf-rj7K3-AAMqMbBZAgQ246.jpg" title="mail8.jpg" style="float:none;" alt="wKiom1Vtf-rj7K3-AAMqMbBZAgQ246.jpg" />

配置完成,輸入y繼續安裝包;/usr/local/src/iRedMail-0.9.1/config 設定檔儲存使用者名稱和密碼,需要移動到一個安全的地方;

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6D/DD/wKiom1Vtf_GxhMq-AAKlY46AqSs224.jpg" title="mail9.jpg" style="float:none;" alt="wKiom1Vtf_GxhMq-AAKlY46AqSs224.jpg" />

禁用selinux,防火牆規則是否提供選擇n,使用mysql設定檔選擇y;

[ INFO ] Disable SELinux in /etc/selinux/config.< Question > Would you like to use firewall rules provided by iRedMail?< Question > File: /etc/sysconfig/iptables, with SSHD port: 22. [Y|n]n[ INFO ] Skip firewall rules.< Question > Would you like to use MySQL configuration file shipped within iRedMail now?< Question > File: /etc/my.cnf. [Y|n]y

安裝完成後,會顯示登入webmail及iredAdmin背景地址,使用者名稱和密碼;


2、使用郵箱系統

安裝完後,看下這些服務是否啟動: 使用命令pstree

for  s in  httpd   iredapd  amavisd  clamd  postfix  dovecot  cbpolicyd  spamassassin  clamd.amavisd  saslauthd   fail2ban; do /etc/init.d/$s restart; done


安裝完成後,先登入iredadmin後台httpS://mail.huangxiaofan.com/iredadmin/

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/6D/DD/wKiom1VtgvmCze6SAAHISd1AFDs759.jpg" style="float:none;" title="mail10.jpg" alt="wKiom1VtgvmCze6SAAHISd1AFDs759.jpg" />

登入之後的介面顯示mysql和伺服器相關資訊

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />選擇功能表列Admins,修改管理員的屬性,可以選擇簡體中文顯示;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/6D/DD/wKiom1VtgwaCEiK5AAGzLwv3ODc136.jpg" title="mail12.jpg" style="float:none;" alt="wKiom1VtgwaCEiK5AAGzLwv3ODc136.jpg" />

添加——使用者,設定郵件地址及密碼;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/6D/D9/wKioL1VthKKAIY2MAACrKV5u1cI486.jpg" title="mail13.jpg" style="float:none;" alt="wKioL1VthKKAIY2MAACrKV5u1cI486.jpg" />

登入Roundcube系統 httpS://mail.huangxiaofan.com/mail/    使用建立的新使用者登入,測試收發郵件;

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/6D/DD/wKiom1Vtgw3CswK1AAMPKkyRkTA416.jpg" title="mail14.jpg" style="float:none;" alt="wKiom1Vtgw3CswK1AAMPKkyRkTA416.jpg" />

發送郵件速度較快,收取郵件較慢,QQ郵箱收取郵件大概要幾分鐘;

發送大附件內容2M,上傳附件速度很慢,QQ郵箱收取大概1-2分鐘;QQ發送過來的接收很慢,10分鐘以上;


發郵件正常,收郵件非常慢,是因為Policyd服務造成的,解決辦法:

vim /etc/policyd/cluebringer.conf  //找到 Greylisting這個模組,在前面加#

然後重啟dovecot/postfix/cbpolicyd服務 : 

service dovecot restart; service postfix restart; service cbpolicyd restart


簡單的郵件伺服器搭建完畢,對於中小企業需求不大的話可以考慮使用;


本文出自 “模範生的學習部落格” 部落格,請務必保留此出處http://8802265.blog.51cto.com/8792265/1657623

linux下搭建iredmail郵件伺服器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.