火冰狐 发表于 2018-5-10 13:30:05

Redhat 5.4 安装postfix

  一、Postfix介绍
  Postfix是一款非常优异的邮件服务器,它可以说是用来替代Sendmail的。Postfix主要是用在邮件服务器的发信上,也就是采用SMTP来进行发邮件,而收信则一般采用Dovecot来实现。
  

  1. postfix是免费的
  postfix想要作用的范围是广大的Internet用户,试图影响大多数的Internet上的电子邮件系统,因此它是免费的。
  2. 更快
  postfix在性能上大约比sendmail快三倍。一部运行postfix的台式PC每天可以收发上百万封邮件。
  3. 兼容性好
  postfix是sendmail兼容的,从而使sendmail用户可以很方便地迁移到postfix。Postfix支持/var/mail、/etc/aliases、 NIS、和 ~/.forward 文件。
  4. 更健壮
  postfix被设计成在重负荷之下仍然可以正常工作。当系统运行超出了可用的内存或磁盘空间时,postfix会自动减少运行进程的数目。当处理的邮件数目增长时,postfix运行的进程不会跟着增加。
  5. 更灵活
  postfix是由超过一打的小程序组成的,每个程序完成特定的功能。你可以通过配置文件设置每个程序的运行参数。
  6. 安全性
  postfix具有多层防御结构,可以有效地抵御恶意入侵者。如大多数的postfix程序可以运行在较低的权限之下,不可以通过网络访问安全性相关的本地投递程序等等。
  

  

  二、Postfix的安装和配置
  Postfix的官方网站是:http://www.postfix.org/
  

  1、查看postfix是否安装
  rpm -qa | grep postfix

  

  2.安装postfix
  yum install postfix
  

  3.卸载sendmail
  rpm -e sendmail
  yum -y remove sendmail
  

  4.配置postfix
  

  新建配置文件
  postconf -n > /etc/postfix/main2.cf
  

  备份配置文件
  mv /etc/postfix/main.cf /etc/postfix/main.cf.bak
  

  更改配置文件名字
  mv /etc/postfix/main2.cf /etc/postfix/main.cf
  

  编辑配置文件
  vi /etc/postfix/main.cf
  增加如下内容:
  

  # hostname
  mynetworks = 127.0.0.1
  myhostname = mail.extmail.org
  mydestination = $mynetworks $myhostname
  

  # banner
  mail_name = Postfix - by extmail.org
  smtpd_banner = $myhostname ESMTP $mail_name
  

  # response immediately
  smtpd_error_sleep_time = 0s
  

  # Message and return code control
  message_size_limit = 5242880
  mailbox_size_limit = 5242880
  show_user_unknown_table_name = no
  

  # Queue lifetime control
  bounce_queue_lifetime = 1d
  maximal_queue_lifetime = 1d
  

  完整的配置文件
  # cat /etc/postfix/main.cf
  alias_database = hash:/etc/aliases
  alias_maps = hash:/etc/aliases
  command_directory = /usr/sbin
  config_directory = /etc/postfix
  daemon_directory = /usr/libexec/postfix
  data_directory = /var/lib/postfix
  debug_peer_level = 2
  html_directory = no
  inet_interfaces = localhost
  mail_owner = postfix
  mailq_path = /usr/bin/mailq.postfix
  manpage_directory = /usr/share/man
  mydestination = $myhostname, localhost.$mydomain, localhost
  newaliases_path = /usr/bin/newaliases.postfix
  queue_directory = /var/spool/postfix
  readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
  sample_directory = /usr/share/doc/postfix-2.3.3/samples
  sendmail_path = /usr/sbin/sendmail.postfix
  setgid_group = postdrop
  unknown_local_recipient_reject_code = 550
  

  

  # hostname
  mynetworks = 127.0.0.1
  myhostname = mail.extmail.org
  mydestination = $mynetworks $myhostname
  

  # banner
  mail_name = Postfix - by extmail.org
  smtpd_banner = $myhostname ESMTP $mail_name
  

  # response immediately
  smtpd_error_sleep_time = 0s
  

  # Message and return code control
  message_size_limit = 5242880
  mailbox_size_limit = 5242880
  show_user_unknown_table_name = no
  

  # Queue lifetime control
  bounce_queue_lifetime = 1d
  maximal_queue_lifetime = 1d
  

  

  5.启动postfix服务:
  service postfix restart
  

  6.查看端口25是否开启
  netstat -lanpt |grep 25
  tcp      0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      3315/master
  

  telnet localhost 25
  

  7.发送一封主题是test的测试邮件
# mail -s test flyshai@126.com 回车之后按ctrl+d,再回车
  Cc:
  Null message body; hope that's ok
  

  8.查看邮件是否发送成功
# tail -f /var/log/maillog
  Mar5 03:58:09 localhost postfix/smtp: ED16C1BDD5D: to=<flyshai@126.com>, relay=58.32.186.231:25, delay=0.3, delays=0.02/0/0.18/0.1, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 0245B33032F)
  

  

  
页: [1]
查看完整版本: Redhat 5.4 安装postfix