爱谁谁a 发表于 2015-9-15 10:31:09

使用postfix搭建匿名smtp服务器

  iDaemon » 使用postfix搭建匿名smtp服务器
使用postfix搭建匿名smtp服务器

  昨天尝试架设了sendmail作为smtp服务器发信,今天换用了传说中评价更好的postfix来实验。
  
  零. 环境简介
  Centos 5.7 x64
  postfix-2.3.3-2.3.el5_6
  Postfix与sendmail相比的主要优点:
  1. 效率更高,并完全兼容sendmail;
  2. 健壮可靠,内存不足时会自动减少线程,保证可用性;
  3. 使用灵活,各组分都可以定制参数,完成特定的某个功能;
  4. 安全性高,易于扩展和二次开发。
  
  一. 搭建流程
  1. 禁用sendmail
  service sendmail stop
  chkconfig sendmail off
  2. 安装postfix
  yum install postfix -y
  3. 配置postfix的conf
  vi /etc/postfix/main.cf
  mydomain=test.com
  myorigin=$mydomain
  inet_interfaces=all
  # 注意,要把默认的inet_interfaces=localhost删除或注释掉
  mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
  mynetworks=10.0.0.0/8, 127.0.0.0/8
  # 内网用
  4. 检测conf
  postconf -n
  如果未报错,即通过检测
  5. 启动postfix并添加到自启动
  service postfix start
  chkconfig postfix on
  
  二. smtp发信测试
  # telnet 127.0.0.1 25
  Trying 127.0.0.1…
  Connected to Mornitor (127.0.0.1).
  Escape character is ‘^]’.
  220 CentOS.test.com ESMTP Postfix
  helo test.com
  250 CentOS.test.com
  mail from: f@fda.com
  250 2.1.0 Ok
  rcpt to:XXXXXX@139.com
  # 此处邮件地址隐去 http://iDaemon.net/wp-includes/images/smilies/icon_razz.gif
  250 2.1.5 Ok
  data
  354 End data with <CR><LF>.<CR><LF>
  subject:test
  this is a test mail
  .
  250 2.0.0 Ok: queued as 5F92D110044
  quit
  Feb 3 12:34:45 Mornitor postfix/qmgr: 5F92D110044: from=<f@fda.com>, size=344, nrcpt=1 (queue active)
  Feb 3 12:34:59 Mornitor postfix/smtp: 5F92D110044: enabling PIX <CRLF>.<CRLF> workaround for mx1.mail.139.com:25
  Feb 3 12:35:10 Mornitor postfix/smtp: 5F92D110044: to=<XXXXXX@139.com>, relay=mx1.mail.139.com:25, delay=1930, delays=1905/0.01/12/13, dsn=2.0.0, status=sent (250 ok)
  Feb 3 12:35:10 Mornitor postfix/qmgr: 5F92D110044: removed
  片刻后手机也收到了该邮件,测试成功
  
  三. 备注
  1. postfix的配置与sendmail相比同样便捷,几分钟内即可搭建出一个可用的测试发信服务器;
  2. sendmail一般在centos中直接内置并已设置为默认MTA,如果没有特殊需求可以直接拿来用;
  3. 如果为了长远使用,还是选择postfix较为合适,它可以很方便地加上各类扩展,如反垃圾,防病毒等。
  4. saslauthd 为实现SMTP认证的必选组件,此篇笔记中由于无此需求,予以省略了;
  5. 无论使用何种MTA架设匿名smtp,一定要注意设置访问策略,防止被恶意用户利用,发送大量垃圾邮件!
  
  四. 主要参考文献
  余洪春. (2011). 构建高可用Linux服务器. 北京: 机械工业出版社. P501-502.

Posted on 2011 年 12 月 28 日 by idaemon.This entry was posted in Mail and tagged postfix, sendmail, smtp. Bookmark the permalink.
页: [1]
查看完整版本: 使用postfix搭建匿名smtp服务器