linux7.4邮件服务器,Centos7.4搭建邮件收发服务器(部署篇)
電子郵件基本概念
1.MUA(Mail User Agent)
MUA接受郵件所使用的郵件客戶端,使用IMAP或POP3協議與服務器通信。(比如:outlook,foxmail等)
2.MTA(Mail Transfer Agent)
MTA通過SMTP協議發送、轉發郵件(比如:sendmail,postfix)
3.MDA(MailDeliver Agent)
MDA將MTA接收到的郵件保存到磁盤或指定方,通常會進行垃圾郵件和病毒掃描(promail,dropmail)
4.MRA(Mail Receive Agent)
負責實現IMAP與POP3協議,與MUA進行交互。(比如:dovecot)
5.SMTP(Simple Mail Transfer Protocol)
傳輸發送郵件所使用的標準協議之一
6.IMAP(Internet Message Access Protocol)
接收郵件使用的標準協議之一
7.POP3(Post Office Protocol)
接收郵件使用的標準協議之一
郵件服務器架構圖
郵件服務器部署步驟
一、郵件服務器壞境
騰訊云
服務器系統:Centos7.4 64bit
二、域名解析
1.登錄騰訊云控制臺->選擇域名服務菜單->選擇域名->管理。
2.添加域名解析記錄如下:
主機記錄記錄類型線路類型記錄值MX優先級TTL(秒)@MX默認mail.loachblog.com5600
mailA默認183.42.13.1335600
3.測試域名mail解析是否成功
#打開win7或win10 win+r 輸入CMD命令
>nslookup
>set type=mx
>mail.yourdomain.com
#出現下面結果,表示域名mail解析成功
非權威應答:
名稱: mail.loachblog.com
Address: 183.42.13.133
三、安裝mail服務器相關軟件
1.安裝postfix
#因為sendmail軟件,一般centos會自帶,而我們這里用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軟件相關參數
1.配置postfix下的main.cf文件如下:
:set number 顯示行號
#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(你的服務器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
#如果要打開465端口,則需要進行一下配置
vi/etc/postfix/master.cf
#12行加上
smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes
2.配置dovecot相關配置文件
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 #指定以本地系統用戶認證
vi /usr/lib64/sasl2/smtpd.conf
#沒有改文件,則創建,代碼如下
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level:3
五、啟動服務
systemctl start postfix.service
systemctl start dovecot.service
systemctl start saslauthd
六、創建郵件賬號,客戶端測試收發郵件
1.創建賬號密碼
#創建賬號
useradd test6
#創建賬號密碼
passwd test6
2.下載mail客戶端,推薦使用foxmail3.登錄foxmail,配置如下
登錄參數接受服務器類型POP3
郵件賬號test6@loachblog.com
密碼test6passwod
pop服務器:loachblog.com勾選SSL 端口995
SMTP服務器:loachblog.com勾選SSL 端口465
4.收發郵件注意事項由于QQ和163郵箱發垃圾郵件比較嚴格,需要在自己的QQ和163郵件管理中心,將自己的域名設置為白名單,不然郵件會被退回。
總結
折騰了2個星期總算搞定了,一些配置也不是很明白。不過算是了解了一些基本原理。剛開始配置好了后,自己又重新卸載,再裝了一次,算是加深映像。這是郵件服務器的配置和部署。關于怎么反垃圾郵件、配置數據庫等一些配置,也是以后研究的方向。
總結
以上是生活随笔為你收集整理的linux7.4邮件服务器,Centos7.4搭建邮件收发服务器(部署篇)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [剑指offer][JAVA][面试题第
- 下一篇: 台式计算机模拟软件,仿真软件 计算机仿