自主搭建邮件服务器
郵件服務(wù)器搭建
一、mail服務(wù)器初始化配置
1.修改主機(jī)名
[root@localhost /]# hostnamectl --static set-hostname mail.drock.top|bash2.關(guān)閉防火墻和selinux
[root@localhost /]# systemctl stop firewalld && systemctl disable firewalld [root@localhost /]# setenforce 03.同步時(shí)間
[root@localhost /]# yum -y install ntpdate && ntpdate ntp.aliyun.com4.安裝軟件
[root@localhost /]# yum -y install postfix dovecot cyrus-sasl-* mailx二、修改配置文件
1.配置postfix,備份cp /etc/postfix/main.cf /etc/postfix/main-old.cf
[root@localhost /]# cat /etc/postfix/main.cfmail_owner = postfixmyhostname = mail.liqing-test.topmydomain = liqing-test.topmyorigin = $mydomaininet_interfaces = allinet_protocols = ipv4mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomainlocal_recipient_maps mynetworks = 0.0.0.0/0relay_domains = $mydestinationalias_maps = hash:/etc/aliasesalias_database = hash:/etc/aliasessmtpd_banner = $myhostname ESMTP# 在最下面新增smtpd_sasl_type = dovecotsmtpd_sasl_path = private/authsmtpd_sasl_local_domain =smtpd_sasl_auth_enable = yessmtpd_sasl_security_options = noanonymousbroken_sasl_auth_clients = yessmtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticatedsmtpd_client_restrictions = permit_sasl_authenticated2.配置dovectot
?2.1配置監(jiān)聽協(xié)議:
[root@localhost /]# cat /etc/dovecot/dovecot.confprotocols = imap pop3 lmtplisten = *login_trusted_networks = 0.0.0.0/0dict {}!include conf.d/*.conf!include_try local.conf2.2配置登錄方式
[root@localhost /]# cat /etc/dovecot/conf.d/10-auth.confdisable_plaintext_auth = noauth_mechanisms = plain login!include auth-system.conf.ext2.3配置郵件存儲(chǔ)位置
[root@localhost /]# cat /etc/dovecot/conf.d/10-mail.confmail_location = mbox:~/mail:INBOX=/var/mail/%unamespace inbox {inbox = yes}first_valid_uid = 1000mbox_write_locks = fcntl [root@localhost /]# cat /etc/dovecot/conf.d/10-master.confservice auth {unix_listener /var/spool/postfix/private/auth {mode = 0666user = postfixgroup = postfix}}2.4配置ssl(關(guān)閉)
[root@localhost /]# cat /etc/dovecot/conf.d/10-ssl.confssl = no3.配置sasl2
3.1配置系統(tǒng)認(rèn)證
[root@localhost /]# cat /etc/sysconfig/saslauthdSOCKETDIR=/run/saslauthdMECH=shadowFLAGS=3.2配置登錄方式
[root@localhost /]# cat /etc/sasl2/smtpd.confpwcheck_method: saslauthdmech_list: PLAIN LOGINlog_level:34.啟動(dòng)服務(wù)
[root@localhost /]# systemctl?restart?dovecot[root@localhost /]# systemctl?restart?postfix[root@localhost /]# systemctl restart?saslauthd[root@localhost /]# systemctl?enable dovecot[root@localhost /]# systemctl?enable postfix[root@localhost /]# systemctl enable saslauthd5.創(chuàng)建用戶并設(shè)置pass
[root@localhost /]# useradd -m drock && echo 123456 | passwd --stdin drock[root@localhost /]# su - drock[drock@mail ~]$ mkdir -p ~/mail/.imap/INBOX[drock@mail ~]$ chmod -R 750 ~/mail??????? #(這不操作不做會(huì)在使用foxmail登錄時(shí)報(bào)錯(cuò){Error: Couldn't open INBOX: Permission denied})[drock@mail ~]$ exit6.配置mailx
[root@localhost /]# vi?/etc/mail.rcset from=drock@drock.topset smtp=mail.drock.topset smtp-auth-user=drockset smtp-auth-password=123456set smtp-auth=login四、發(fā)送郵件測試
1.命令行發(fā)送郵件測試
[root@localhost /]# echo?"郵件服務(wù)器測試"?| mail?-s?"郵件服務(wù)器測試" other-email@163.com2.使用foxmail登錄并發(fā)送郵件測試
五、報(bào)錯(cuò)
1.權(quán)限被拒絕
在使用foxmail登錄郵箱時(shí)提示權(quán)限被拒絕,這是因?yàn)樵卩]箱用戶的家目錄下mail文件權(quán)限不是750,設(shè)置為750后解決。
[drock@mail ~]$ chmod -R 750 ~/mail2.無法找到主機(jī)
郵件在發(fā)送時(shí)會(huì)根據(jù)郵件地址的解析記錄去查找mx記錄,這里我在向騰訊的企業(yè)郵箱發(fā)送測試郵件時(shí)找不到騰訊的郵箱地址。我在內(nèi)網(wǎng)的dns代理中加入了騰訊的mx記錄后解決
[root@dns- ~]# grep qq /etc/dnsmasq.confmx-host=***.com,mxbiz2.qq.com,10mx-host=***.com,mxbiz1.qq.com,53.郵件被拒絕
在我向騰訊企業(yè)郵箱發(fā)送測試郵件時(shí)日志里出現(xiàn)了550郵件連接被拒絕的情況,此情況在郵件中設(shè)置白名單后解決。
總結(jié)
- 上一篇: vue 局部回到顶部_vue中回到顶部
- 下一篇: vijos1214——伤心的AsukaN