postfix+dovecot配置多域名邮件服务器
mail郵局系統的MX(郵件交換)記錄配置,以便收發郵件。(MX記錄,是郵件交換記錄,它指向一個郵件服務器,用于電子郵件系統發郵件時根據收信人的地址后綴來定位郵件服務器,如果沒有做域名解析,郵局不能正常使用,即不能正常的發送或者接收郵件。)
一、安裝postfix和dovecot
yum install postfix dovecot
chkconfig postfix on
chkconfig dovecot on
也可以用一次安裝所有依賴包yum install sysstatpostfixcrontabs redhat-lsb-graphicsredhat-lsb-corearpwatchcronie dovecot
1、配置postfix
vi /etc/postfix/main.cf
# change or add on these line:
myhostname = yes81.net
mydomain = yes81.net
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8
home_mailbox = Maildir/
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, permit
broken_sasl_auth_clients = yes
2、dovecot配置
vi /etc/dovecot/dovecot.conf
# uncomment on this line:
protocols = imap pop3
listen = *
3、配置認證方式
vi /etc/dovecot/conf.d/10-auth.conf
# change on these line:
disable_plaintext_auth = no
auth_mechanisms = plain login
4、設置郵箱文件夾
vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
5、配置認證
vi /etc/dovecot/conf.d/10-master.conf
# commented on these line:
#unix_listener auth-userdb {
#mode = 0600
#user =
#group =
#}
# change or setup on these line:
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
6、配置pop3
vi /etc/dovecot/conf.d/20-pop3.conf
# uncomment on these line:
pop3_uidl_format = %08Xu%08Xv
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
7、重啟dovecot、postfix
Service dovecot restart
Service postfix restart
8、增加用戶和設置用戶密碼
這個時候就可以增加用戶和設置用戶密碼,然后測試收發
groupadd mailuser
adduser -g mailuser -s /sbin/nologin test1
passwdtest1
adduser -g mailuser -s /sbin/nologin test2
passwdtest2
打開FOXMAIL等郵件工具測試,能正常收發,就表示系統可以了。
test1@mail.yes81.nettest2@mail.yes81.net
二、如果無法發信
試著發送郵件,如果發送不出去,查看日志文件/var/log/maillog如果顯示:
postfix/smtp[17105]: fatal: unknown service: smtp/tcp
postfix/smtpd: disconnect from unknown[113.64.242.145]
postfix/qmgr: warning: private/smtp socket: malformed response
postfix/qmgr: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
postfix/master: warning: process /usr/libexec/postfix/smtp pid 17105 exit status 1
postfix/master: warning: /usr/libexec/postfix/smtp: bad command startup -- throttling
這是由于郵件默認的postfix賬號無法執行/etc/services,權限不足所致。查看service的權限為640:
Chmod 644 /etc/services于是將其改為644:
重新啟動2個服務后就可以看到,一切正常了!
三、如何添加虛擬域名:
http://www.postfix.org/VIRTUAL_README.html
按照官方指導,對于多域名的支持postfix支持以下幾種方式:
1.共享域名,共享Unix賬戶
2.虛擬別名(Virtual Alias)獨立域名,共享Unix賬戶
3.虛擬郵箱(Virtual Mailbox)獨立域名,無需Unix賬戶
4.轉發服務器(Forwarding Server)用做備份服務器,主服務器故障時暫存郵件,恢復后直接轉發給主服務器
從官網查到后,決定采用第2種方法:虛擬別名(Virtual Alias)獨立域名,共享Unix賬戶
vi /etc/postfix/main.cf virtual_alias_domains = t3t3.org
virtual_alias_maps = hash:/etc/postfix/virtual
alias_maps=hash:/etc/aliases
vi /etc/postfix/virtual
test1@t3t3.org test1
test2@t3t3.org test2
test1@yes81.net test1
test2@yes81.net test2
vi /etc/aliases //把剛添加的帳號做個別名 test1: test1
test2: test2
postmap /etc/postfix/virtual//reload數據庫后需新域名就可以使用了
postalias /etc/aliases//postfix/etc/aliases命令是否等同?
newaliases
postfixreload//reload
Service dovecot restart//重新啟動
Service postfix restart//重新啟動
如果操作postfix/etc/aliases時候出現/usr/libexec/postfix/postfix-script: line 337: /etc/aliases: Permission denied則需要修改權限:
chmod 664 /etc/aliases
chown root /etc/aliases
chmod 755 /etc/aliases.db
chown smmsp /etc/aliases.db
修改好權限后,再次執行reload和重新等命令
如此后郵件服務器就可以用test1@yes81.nettest1@t3t3.org進行收發郵件了。
總結
以上是生活随笔為你收集整理的postfix+dovecot配置多域名邮件服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 蓝戟Intel Arc A380独立显卡
- 下一篇: ETC信用卡可以提现吗 透支取现有限额