`
victorwmh
  • 浏览: 207561 次
  • 性别: Icon_minigender_1
  • 来自: 宇宙
社区版块
存档分类
最新评论

Postfix替代sendmail发送邮件

 
阅读更多

基础知识
    MUA: Mail User Agent(邮件用户代理),例如:mutt、elm、Pine、Outlook、Foxmail
    MUA的任务:

    MAA: Mail Access Agent(邮件访问代理),可以算是MTA的一个子系统。

    MTA: Mail Transfer Agent(邮件传输代理),例如:Sendmail、qmail、postfix
    MTA的任务:

    MDA:Mail Delivery Agent(邮件投递代理)
    MDA的任务:

    用于传递信息的标准协议:
    SMTP:Simple Mail Transfer Protocol(简单邮件传输协议,RFC 2821)

    用于接收的协议:
    POP:Post Office Protocol(邮局协议,RFC 1939)
    POP3:
    IMAP: Internet Message Access Protocol(交互邮件访问协议,RFC 2060)

    注:RFC即Request For Comments的缩写,IETF(Internet Engineering Task Force)维护各种各样标准与协议规范的一种方式。

一、关闭sendmail

   关闭已经运行的MTA软件,linux默认安装了sendmail,所以需要先使用下列命令停止:
   # killall sendmail (停止所有的Sendmail进程)
   或者
   # service sendmail stop
   # chkconfig sendmail off  (关闭sendmail 开机的启动)
   # chkconfig --list         (查看下自动启动的程序)
   
   卸载sendmail
   # rpm -e sendmail --nodeps

二、安装postfix

   # yum install postfix
   
   # newaliases (生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低)
   
   更改配置文件(/etc/postfix/main.cf)中的参数
   # postconf -e myhostname=mail.df3c.com
   # postconf -e myorigin=df3c.com
   # postconf -e mydomain=df3c.com
   # postconf -e mydestination=localhost
   # postconf -e mynetworks=127.0.0.0/8

   这几个参数主要是控制,邮件发送和接受的默认值。

   参数具体含义,可以参考:《Postfix权威指南》

   启动停止及启用更新的参数
   # postfix start
   # postfix stop
   # postfix reload
   
   日志文件
   # more /var/log/maillog
   或者
   # cat /var/log/maillog

   注:每次重启或更新postfix的参数后,注意查看日志,确实是否正常。

 

   测试:

   # telnet localhost 25

ehlo mail
mail from:server#df3c.com
rcpt to:wmh@126.com
data
This is a test mail.
.
quit
 

三、相关问题

   1、网络监听的问题
   # postconf inet_interfaces = all
   inet_interfaces为all表示所有IP,localhost则为127.0.0.1
  
   如果只是用Postfix代替sendmail发送邮件,而不接收邮件的话,可以将inet_interfaces的值设为localhost。
   这样将大大增加服务器的安全。
  
   2、防垃圾邮件(spamhaus)联盟,造成(国外、sina等)邮箱无法收信
   访问http://www.spamhaus.org/lookup.lasso,输入IP地址查找是否在垃圾邮件列表中。
   在的话,可以申请删除,具体步骤可以参考:
   http://www.ff-bb.cn/logs/74631918.html

   3、给gmail发邮件,报类似如下错误:
   host gmail-smtp-in.l.google.com[209.85.147.27] said:550-5.7.1 [220.135.57.87] The IP you're using to send email is not authorized 550-5.7.1 to send email directly to our servers. Please use 550 5.7.1 the SMTP relay at your service provider instead. j21si8542316wah (in reply to end of DATA command)
  
   将/etc/postfix/main.cf中的mydestination参数做如下调整:
   mydestination = $myhostname,localhost.$mydomain,localhost,$mydomain,mail.$mydomain,www.$mydomain
   改为
   mydestination = localhost,localhost.$mydomain,$myhostname,$mydomain,mail.$mydomain,www.$mydomain
   将localhost排前面。

   4、给gmail,yahoo等发邮件被退回
   邮件退回的大多原因,是该邮件服务器域名没做MX反向解析。
   邮箱域名解析设置及MX设置,参加:

   企业邮箱域名解析设置方法
   http://www.net.cn/service/faq/yuming/url/201009/4423.html
   域名MX解析设置方法及其功能
   http://www.net.cn/service/faq/yuming/url/200803/3104.html

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics