CentOS 6、7下配置exim發郵件伺服器
1.配置epel源(exim包位於EPEL軟體源中)
CentOS7
#cat>/etc/yum.repos.d/epel.repo<<EOF[epel]name=ExtraPackagesforEnterpriseLinux7-\$basearch#baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearchfailovermethod=priorityenabled=1gpgcheck=0EOF
CentOS6
#cat>/etc/yum.repos.d/epel.repo<<EOF[epel]name=ExtraPackagesforEnterpriseLinux6-\$basearch#baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearchmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearchfailovermethod=priorityenabled=1gpgcheck=0EOF
2. 禁止postfix
-
#servicepostfixstop
-
#chkconfigpostfixoff
3. 安裝exim
-
#yum-yinstallexim
4. 將exim設為預設的MTA
-
#alternatives--setmta/usr/sbin/sendmail.exim
5. 修改exim設定檔
#vi/etc/exim/exim.conf#幾個參數primary_hostname=mail.flying.com#查看源郵件時顯示Received:frommail.flying.com,如果不指定直接取作業系統的hostnamedomainlistlocal_domains=@localhost:localhost.localdomain:mail.flying.comdomainlistrelay_to_domains=flying.com#允許通過改主機發送郵件的網域名稱hostlistrelay_from_hosts=127.0.0.1:192_32G:10.168.0.0/16:
<br>
-
#允許那些用戶端主機發送郵件,如本地使用這台伺服器發送郵件時,即需要添加本地出口ip地址(公網地址)
6. 測試
-
#yum-yinstallmailx
-
#date|mail-rno-reply@flying.com-s'eximtest'uttflying@foxmail.com
-
#tail-f/var/log/exim/main.log#exim記錄檔
ps:
如果不指定-r(發郵件地址),且你的主機名稱不是xxx.com,可能會報如下錯誤:
SMTP error from remote mail server after MAIL FROM:
錯誤是550 MI:IMF 發信人電子郵件地址不合規範
使用檔案進行郵件發送:
date|mail-rflying@yflying.com-s'SN_IPinfoTEXT'uttflying@163.comwanglei@flying.com</root/cobbler/sn.logmail命令的文法如下:Usage:mail[-iInv][-ssubject][-ccc-addr][-bbcc-addr]to-addr...[--sendmail-options...]mail[-iInNv]-f[name]mail[-iInNv][-uuser]
測試成功