1. 配置epel源(exim包位於EPEL軟件源中)
CentOS7
# cat > /etc/yum.repos.d/epel.repo << EOF [epel] name=Extra Packages for Enterprise Linux 7 - \$basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch failovermethod=priority enabled=1 gpgcheck=0 EOF
CentOS6
# cat > /etc/yum.repos.d/epel.repo << EOF [epel] name=Extra Packages for Enterprise Linux 6 - \$basearch #baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch failovermethod=priority enabled=1 gpgcheck=0 EOF
2. 禁止postfix
# service postfix stop # chkconfig postfix off
3. 安裝exim
# yum -y install exim
4. 將exim設為默認的MTA
# alternatives --set mta /usr/sbin/sendmail.exim
5. 修改exim配置文件
# vi /etc/exim/exim.conf #幾個參數
primary_hostname = mail.linuxeye.com #查看源郵件時顯示Received: from mail.linuxeye.com,如果不指定直接去操作系統的hostname domainlist local_domains = @ localhost : localhost.localdomain :mail.linuxeye.com domainlist relay_to_domains = linuxeye.com #允許通過改主機發送郵件的域名 hostlist relay_from_hosts = 127.0.0.1 : 192_32G : 192.168.0.0/16 : #允許那些客戶端主機發送郵件,如本地使用這台服務器發送郵件時,即需要添加本地出口ip地址(公網地址)
6. 測試
# yum -y install mailx # date | mail -r [email protected] -s 'exim test' [email protected] # tail -f /var/log/exim/main.log #exim日志文件
ps:
如果不指定-r(發郵件地址),且你的主機名不是xxx.com,可能會報如下錯誤:
SMTP error from remote mail server after MAIL FROM:
錯誤是550 MI:IMF 發信人電子郵件地址不合規范
經驗:
強烈建議用網易企業郵箱,如果自己搭建郵件服務器做發郵件,又設置QQ企業郵箱做本地收發服務器會出現地址未驗證問題。