您好,登錄后才能下訂單哦!
小編給大家分享一下Centos7.9如何搭建自主郵件服務器,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
我在內網使用的域名主機是dnsmasq代理軟件,其使用簡單,方便,多樣化。詳細配置可查看其他文檔。
[root@dns_proxy ~]# grep liqing /etc/dnsmasq.conf address=/mail.liqing-test.top/192.168.2.100 mx-host=liqing-test.top,mail.liqing-test.top,10
[root@localhost /]# hostnamectl --static set-hostname mail.liqing-test.top|bash
[root@mail /]# systemctl stop iptables && systemctl disable iptables [root@mail /]# systemctl stop firewalld && systemctl disable firewalld [root@mail /]# setenforce 0
[root@mail /]# yum -y install ntpdate && ntpdate ntp.aliyun.com
[root@mail /]# yum -y install postfix dovecot cyrus-sasl-* mailx
注釋:配置文件備份操作本文檔自行操作
[root@mail /]# cat /etc/postfix/main.cf mail_owner = postfix myhostname = mail.liqing-test.top mydomain = liqing-test.top 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 relay_domains = $mydestination alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases smtpd_banner = $myhostname ESMTP # 在最下面新增 smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated smtpd_client_restrictions = permit_sasl_authenticated
[root@mail /]# cat /etc/dovecot/dovecot.conf protocols = imap pop3 lmtp listen = * login_trusted_networks = 0.0.0.0/0 dict { } !include conf.d/*.conf !include_try local.conf
[root@mail /]# cat /etc/dovecot/conf.d/10-auth.conf disable_plaintext_auth = no auth_mechanisms = plain login !include auth-system.conf.ext
[root@mail /]# cat /etc/dovecot/conf.d/10-mail.conf mail_location = mbox:~/mail:INBOX=/var/mail/%u namespace inbox { inbox = yes } first_valid_uid = 1000 mbox_write_locks = fcntl
[root@mail /]# cat /etc/dovecot/conf.d/10-master.conf service auth { unix_listener /var/spool/postfix/private/auth { mode = 0666 user = postfix group = postfix } }
[root@mail /]# cat /etc/dovecot/conf.d/10-ssl.conf ssl = no
[root@mail /]# cat /etc/sysconfig/saslauthd SOCKETDIR=/run/saslauthd MECH=shadow FLAGS=
[root@mail /]# cat /etc/sasl2/smtpd.conf pwcheck_method: saslauthd mech_list: PLAIN LOGIN log_level:3
systemctl restart dovecot systemctl restart postfix systemctl restart saslauthd systemctl enable dovecot systemctl enable postfix systemctl enable saslauthd
[root@mail /]# useradd -m autumn && echo 123456 | passwd --stdin autumn [root@mail /]# su - autumn [autumn@mail ~]$ mkdir -p ~/mail/.imap/INBOX [autumn@mail ~]$ chmod -R 750 ~/mail #(這不操作不做會在使用foxmail登錄時報錯{Error: Couldn't open INBOX: Permission denied}) [autumn@mail ~]$ exit
[root@mail /]# cat /etc/mail.rc set from=autumn@liqing-test.top set smtp=mail.liqing-test.top set smtp-auth-user=autumn set smtp-auth-password=123456 set smtp-auth=login
[root@mail /]# echo "郵件服務器測試" | mail -s "郵件服務器測試" other-email@163.com
在使用foxmail登錄郵箱時提示權限被拒絕,這是因為在郵箱用戶的家目錄下mail文件權限不是750,設置為750后解決。
[autumn@mail ~]$ chmod -R 750 ~/mail
Dec 3 10:15:35 Git-server dovecot: pop3-login: Login: user=<autumn>, method=PLAIN, rip=192.168.31.100, lip=192.168.2.100, mpid=24843, secured, session=<YnZ3ezTSjiLAqB9k>
Dec 3 10:15:35 Git-server dovecot: pop3(autumn): Error: fchown(/home/autumn/mail/.imap, group=12(mail)) failed: Operation not permitted (egid=1004(autumn), group based on /var/mail/autumn - see http://wiki2.dovecot.org/Errors/ChgrpNoPerm)
Dec 3 10:15:35 Git-server dovecot: pop3(autumn): Error: Couldn't open INBOX: Permission denied
Dec 3 10:15:35 Git-server dovecot: pop3(autumn): Couldn't open INBOX: Permission denied top=0/0, retr=0/0, del=0/0, size=0
Dec 3 10:16:26 Git-server dovecot: pop3-login: Login: user=<autumn>, method=PLAIN, rip=192.168.31.100, lip=192.168.2.100, mpid=24895, secured, session=<NkWHfjTS2CLAqB9k>
Dec 3 10:16:26 Git-server dovecot: pop3(autumn): Error: fchown(/home/autumn/mail/.imap, group=12(mail)) failed: Operation not permitted (egid=1004(autumn), group based on /var/mail/autumn - see http://wiki2.dovecot.org/Errors/ChgrpNoPerm)
郵件在發送時會根據郵件地址的解析記錄去查找mx記錄,這里我在向騰訊的企業郵箱發送測試郵件時找不到騰訊的郵箱地址。我在內網的dns代理中加入了騰訊的mx記錄后解決
[root@dns- ~]# grep qq /etc/dnsmasq.conf mx-host=***.com,mxbiz2.qq.com,10 mx-host=***.com,mxbiz1.qq.com,5
Dec 3 10:36:14 Git-server postfix/smtpd[26216]: connect from unknown[192.168.31.100]
Dec 3 10:36:15 Git-server postfix/smtpd[26216]: 05C682267F04: client=unknown[192.168.31.100], sasl_method=LOGIN, sasl_username=autumn
Dec 3 10:36:15 Git-server postfix/cleanup[26220]: 05C682267F04: message-id=<202112031036171922345@liqing-test.top>
Dec 3 10:36:15 Git-server postfix/qmgr[25430]: 05C682267F04: from=<autumn@liqing-test.top>, size=1561, nrcpt=1 (queue active)
Dec 3 10:36:15 Git-server postfix/smtpd[26216]: disconnect from unknown[192.168.31.100]
Dec 3 10:36:15 Git-server postfix/smtp[26221]: 05C682267F04: to=<***@***.com>, relay=none, delay=0.11, delays=0.08/0.02/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=***.com type=MX: Host not found, try again)
在我向騰訊企業郵箱發送測試郵件時日志里出現了550郵件連接被拒絕的情況,此情況在郵件中設置白名單后解決。
Dec 3 10:11:57 Git-server postfix/smtpd[24617]: connect from mail.liqing-test.top[192.168.2.100]
Dec 3 10:11:57 Git-server postfix/smtpd[24617]: 4E2292267F04: client=mail.liqing-test.top[192.168.2.100], sasl_method=LOGIN, sasl_username=autumn
Dec 3 10:11:57 Git-server postfix/cleanup[24621]: 4E2292267F04: message-id=<61a97cec.xRtXn6hYj3NI3wI3%autumn@liqing-test.top>
Dec 3 10:11:57 Git-server postfix/qmgr[24504]: 4E2292267F04: from=<autumn@liqing-test.top>, size=541, nrcpt=1 (queue active)
Dec 3 10:11:57 Git-server postfix/smtpd[24617]: disconnect from mail.liqing-test.top[192.168.2.100]
Dec 3 10:11:58 Git-server postfix/smtp[24622]: 4E2292267F04: to=<***@***.com>, relay=mxbiz1.qq.com[183.57.48.34]:25, delay=1.6, delays=0.09/0.03/0.16/1.3, dsn=5.0.0, status=bounced (host mxbiz1.qq.com[183.57.48.34] said: 550 Mail content denied. http://service.exmail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 (in reply to end of DATA command))
看完了這篇文章,相信你對“Centos7.9如何搭建自主郵件服務器”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。