郵件服務(wù)器(postfix+devocot+cyrus-sasl+centos7)

我的博客:https://blog.thuol.com

說明

參考網(wǎng)絡(luò)上其他人文章。將他人技術(shù)文章親自測試并總結(jié)補(bǔ)充。
搭建郵件服務(wù)器需要有一臺公網(wǎng)服務(wù)器和域名
本文使用10.10.10.10代替實際公網(wǎng)ip,使用a.com代替實際域名

郵件服務(wù)器搭建

1 . 郵件服務(wù)器域名解析(主要參數(shù))

記錄類型 主機(jī)記錄 記錄值
A @ 10.10.10.10
A mail 10.10.10.10
MX @ mail.a.com
TXT @ v=spf1 inuyi.cspf.mail.a.com ~all


2 .安裝相關(guān)軟件
卸載 sendmail 服務(wù)(看到網(wǎng)上有文章說這個不好用,那就卸載了吧)

/etc/init.d/sendmail stop     #//停止 sendmail 服務(wù)
yum remove sendmail           #//卸載 sendmail 服務(wù)

安裝 postfix 和 dovecot

yum install postfix dovecot

安裝 cycus-sasl

yum install cyrus-sasl-*

3 .配置相關(guān)軟件
配置 postfix

vim /etc/postfix/main.cf

按照以下進(jìn)行配置,將前面的#號去掉并修改參數(shù)

myhostname=mail.a.com             #這里要換成你自己的郵箱服務(wù)器
mydomain=a.com                    #這里換成你自己的主機(jī)服務(wù)器
myorigin = $mydomain
inet_interfaces = all             ??梢越邮账杏蛎泥]件
inet_protocols = ipv4             #全部小寫,否則報錯
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,mail.$mydomain, www.$mydomain, ftp.$mydomain
local_recipient_maps =
mynetworks =0.0.0.0/0             #設(shè)置內(nèi)網(wǎng)ip
relay_domains = $mydestination
home_mailbox = Maildir/
#以下內(nèi)容直接粘貼到底部
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,reject_unauth_destination,permit_mynetworks
smtpd_client_restrictions = permit_sasl_authenticated

配置 dovecot

vim /etc/dovecot/dovecot.conf
####修改如下內(nèi)
protocols = imap pop3 lmtp
listen = *
vim /etc/dovecot/conf.d/10-auth.conf
####修改如下內(nèi)
disable_plaintext_auth = no
auth_mechanisms = plain
vim /etc/dovecot/conf.d/10-mail.conf
####修改如下內(nèi)
mail_location = maildir:~/Maildir
vim /etc/dovecot/conf.d/10-ssl.conf
####修改如下內(nèi)
ssl = no

配置 sasl2

vim /etc/sysconfig/saslauthd
####修改如下內(nèi)
MECH=shadow  #指定以本地系統(tǒng)用戶名認(rèn)證
vim /usr/lib64/sas12/smtpd.conf    //64位系統(tǒng)
####修改如下內(nèi),如果沒有文件,自行創(chuàng)建該目錄和文件
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level:3

4 .啟動服務(wù)
啟動

systemctl  start  dovecot
systemctl  start  postfix
systemctl  start  saslauthd

停止

systemctl  stop dovecot
systemctl  stop postfix
systemctl  stop saslauthd

查看狀態(tài),出現(xiàn)如下啟動成功

systemctl status postfix


5 .客戶端配置,收發(fā)郵件測試
因為使用系統(tǒng)用戶為賬號要創(chuàng)建一個新賬號

useradd adminmail

修改密碼

passwd adminmail      #輸入兩次密碼賬號創(chuàng)建完成

配置客戶端(本文使用Foxmail)


紅色框內(nèi)輸入自己的配置信息(因為沒有配置證書,不用勾選ssl)




發(fā)送測試




我的126郵箱客戶端在手機(jī)上,已經(jīng)收到郵件。

回復(fù)一下郵件,測試服務(wù)器能收到郵件



說兩句

經(jīng)過測試給126郵箱發(fā)送郵件可以成功,給QQ郵箱發(fā)送出現(xiàn)點問題。返回我如下信息,可能是配置問題?騰訊給攔截了?,有興趣的同學(xué)自己找找解決方案(本文不深入查找了)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容