linux7.4邮件服务器,Centos7.4搭建邮件收发服务器(部署篇)
電子郵件基本概念
1.MUA(Mail User Agent)
MUA接受郵件所使用的郵件客戶端,使用IMAP或POP3協(xié)議與服務(wù)器通信。(比如:outlook,foxmail等)
2.MTA(Mail Transfer Agent)
MTA通過(guò)SMTP協(xié)議發(fā)送、轉(zhuǎn)發(fā)郵件(比如:sendmail,postfix)
3.MDA(MailDeliver Agent)
MDA將MTA接收到的郵件保存到磁盤(pán)或指定方,通常會(huì)進(jìn)行垃圾郵件和病毒掃描(promail,dropmail)
4.MRA(Mail Receive Agent)
負(fù)責(zé)實(shí)現(xiàn)IMAP與POP3協(xié)議,與MUA進(jìn)行交互。(比如:dovecot)
5.SMTP(Simple Mail Transfer Protocol)
傳輸發(fā)送郵件所使用的標(biāo)準(zhǔn)協(xié)議之一
6.IMAP(Internet Message Access Protocol)
接收郵件使用的標(biāo)準(zhǔn)協(xié)議之一
7.POP3(Post Office Protocol)
接收郵件使用的標(biāo)準(zhǔn)協(xié)議之一
郵件服務(wù)器架構(gòu)圖
郵件服務(wù)器部署步驟
一、郵件服務(wù)器壞境
騰訊云
服務(wù)器系統(tǒng):Centos7.4 64bit
二、域名解析
1.登錄騰訊云控制臺(tái)->選擇域名服務(wù)菜單->選擇域名->管理。
2.添加域名解析記錄如下:
主機(jī)記錄記錄類(lèi)型線路類(lèi)型記錄值MX優(yōu)先級(jí)TTL(秒)@MX默認(rèn)mail.loachblog.com5600
mailA默認(rèn)183.42.13.1335600
3.測(cè)試域名mail解析是否成功
#打開(kāi)win7或win10 win+r 輸入CMD命令
>nslookup
>set type=mx
>mail.yourdomain.com
#出現(xiàn)下面結(jié)果,表示域名mail解析成功
非權(quán)威應(yīng)答:
名稱(chēng): mail.loachblog.com
Address: 183.42.13.133
三、安裝mail服務(wù)器相關(guān)軟件
1.安裝postfix
#因?yàn)閟endmail軟件,一般centos會(huì)自帶,而我們這里用postfix搭建,所有先卸載sendmail
yum -y remove sendmail
yum -y install postfix
2.安裝dovecot
yum -y install dovecot
3.安裝cyrus-sasl
yum -y install cyrus-sasl-*
四、配置mail軟件相關(guān)參數(shù)
1.配置postfix下的main.cf文件如下:
:set number 顯示行號(hào)
#main.cf 75行,取消注釋并修改代碼如下
myhostname=mail.loachblog.com
#83行
mydomain=loachblog.com
#98行
myorigin = $mydomain
#113行
inet_interfaces=all
#116行 加上注釋
# inet_interfaces=localohost
#164行
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain,www.$mydomain
#210行
local_recipient_maps =
#264行
mynetworks =183.42.13.133(你的服務(wù)器IP), 168.100.189.0/28, 127.0.0.0/8
#419行 取消注釋
home_mailbox = Maildir/
#shift+G 行尾,加上以下代碼
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem
smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem
smtpd_recipient_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination
#如果要打開(kāi)465端口,則需要進(jìn)行一下配置
vi/etc/postfix/master.cf
#12行加上
smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes
2.配置dovecot相關(guān)配置文件
vi /etc/dovecot/dovecot.conf
#24行 取消注釋
protocols = imap pop3 lmtp
#30行,取消注釋修改如下
listen = *
#在行尾添加一下代碼
mail_location = Maildir:~/Maildir
ssl_cert =
ssl_key =
vi /etc/dovecot/conf.d/10-master.conf
#去掉96-98行的注釋
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user=postfix
group=postfix
}
vi /etc/dovecot/conf.d/10-ssl.conf
#8行
ssl = required
vi /etc/dovecot/conf.d/10-mail.conf
#24行 去掉注釋
mail_location = maildir:~/Maildir
vi /etc/dovecot/conf.d/10-auth.conf
#8行
disable_plaintext_auth = no
#100行
auth_mechanisms = plain login
3.配置sasl2
vi /etc/sysconfig/saslauthd
#7行,修改如下
MECH=shadow #指定以本地系統(tǒng)用戶認(rèn)證
vi /usr/lib64/sasl2/smtpd.conf
#沒(méi)有改文件,則創(chuàng)建,代碼如下
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level:3
五、啟動(dòng)服務(wù)
systemctl start postfix.service
systemctl start dovecot.service
systemctl start saslauthd
六、創(chuàng)建郵件賬號(hào),客戶端測(cè)試收發(fā)郵件
1.創(chuàng)建賬號(hào)密碼
#創(chuàng)建賬號(hào)
useradd test6
#創(chuàng)建賬號(hào)密碼
passwd test6
2.下載mail客戶端,推薦使用foxmail3.登錄foxmail,配置如下
登錄參數(shù)接受服務(wù)器類(lèi)型POP3
郵件賬號(hào)test6@loachblog.com
密碼test6passwod
pop服務(wù)器:loachblog.com勾選SSL 端口995
SMTP服務(wù)器:loachblog.com勾選SSL 端口465
4.收發(fā)郵件注意事項(xiàng)由于QQ和163郵箱發(fā)垃圾郵件比較嚴(yán)格,需要在自己的QQ和163郵件管理中心,將自己的域名設(shè)置為白名單,不然郵件會(huì)被退回。
總結(jié)
折騰了2個(gè)星期總算搞定了,一些配置也不是很明白。不過(guò)算是了解了一些基本原理。剛開(kāi)始配置好了后,自己又重新卸載,再裝了一次,算是加深映像。這是郵件服務(wù)器的配置和部署。關(guān)于怎么反垃圾郵件、配置數(shù)據(jù)庫(kù)等一些配置,也是以后研究的方向。
總結(jié)
以上是生活随笔為你收集整理的linux7.4邮件服务器,Centos7.4搭建邮件收发服务器(部署篇)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [剑指offer][JAVA][面试题第
- 下一篇: 学Linux从编译命令开始——arm-l