如何配置exim,通过gmail向外邮件
debian使用exim4作为默认的邮件传输代理(MTA),利用它通过gmail来发送告警邮件。139邮箱是中国移动推出的一款面向个人用户的互联网邮箱,它有一项独有的功能即短信通知,利用它可以实现短信告警。
一、配置exim4-config
# dpkg-reconfigure exim4-config
说明:[]表示通过光标选择该项,<>表示输入的内容
- 1. [mail sent by smarthost; no local mail]
- 2. system mail name: <net-mgmt.dingan.gov>
- 3. IP-address to listen on for incoming SMTP connections: 127.0.0.1
- 4. Other destinations for which mail is accepted: <null>
- 5. visible domain name for local users: <net-mgmt.dingan.gov>
- 6. IP address or host name of the outgoing smarthost: <smtp.gmail.com::587>
- 7. Keep number of DNS-queries minial(Dial-on-Demand)? : [No]
- 8. split configuration into small files?: [No]
因为上述的步骤只是更新了/etc/exim4.conf.conf,因此还需要执行
# update-exim4.conf
这样才能更新exim4实际用到的配置文件。
二、添加gmail账号和密码
# chown root:Debian-exim /etc/exim4/passwd.client
# vim /etc/exim4/passwd.client 添加如下行, 注意修改用户名和密码
gmail-smtp.l.google.com:yourAccountName@gmail.com:y0uRpaSsw0RD
*.google.com:yourAccountName@gmail.com:y0uRpaSsw0RD
smtp.gmail.com:yourAccountName@gmail.com:y0uRpaSsw0RD
三、重启
# /etc/init.d/exim4 restart
四、测试
# mutt -s “exim4 test mail” 1390750xxxx@139.com< mail.txt
用户可以通过任一文本编辑器来创建mail.txt
五、排错
可以使用tail来查看exim4的日志
# tail -f /var/log/exim4/mainlog
2010-02-02 00:31:21 1NcEAC-0001Al-Cr => 1390750xxxx@139.com R=smarthost =remote_smtp_smarthost H=gmail-smtp-msa.l.google.com [74.125.95.109] X=TLS1.0:RSA_ARCFOUR_MD5:16 DN=”C=US,ST=California,L=Mountain View,O=Google Inc,CN=smtp.gmail.com”
目标邮箱建议选用139邮箱,因为139邮箱还有短信通知,从而变相的实现短信告警功能。