`

postfix个人完全配置手册

 
阅读更多
http://blog.sina.com.cn/s/blog_485acedb010080gi.html

#killall sendmail (停止所有的Sendmaail进程)
启动postfix + dovecot服务过程:
    # service postfix start
    Starting postfix:                             [ 确定 ]
    # service dovecot start
    启动 Dovecot Imap:                         [ 确定 ]
修改/etc/dovecot.conf文件:
    #protocols = imap imap3
    更改为:
    protocols = imap imap3 pop3 pop3s (启动imap imap3 pop3 pop3s功能)
    # service dovecot restart(重新启动dovecot服务)
    停止 Dovecot Imap:                           [ 确定 ]
    启动 Dovecot Imap:                           [ 确定 ]
修改/etc/postfix/main.cf文件:
    myhostname = mail.example.com(指定运行Postfix邮件系统的主机名称)
    mydomain = nseasy.net (指定Postfix邮件系统使用的域名比例:example.com)
    #myorigin = $mydomain (指定发件人所在的域名比例:example.com)
    Inet_interfaces =all (指定Postfix邮件系统监视的网络接口)
    mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain,ftp.$mydomain (指定Postfix接收邮件时收件人的域名)
    mynetworks = 172.16.33.0/24 (指定您所在的网络地址)
  
    # service postfix restart (重新启动postfix服务)
    Shutting down postfix:                         [ 确定 ]
    Starting postfix:                             [ 确定 ]
加主机名:
   vi /etc/hosts
   172.16.33.11            mail.example.com example.com
本地主机解析:
[root@mail ~]# ping mail.example.com
PING mail.example.com (172.16.33.11) 56(84) bytes of data.
64 bytes from mail.example.com (172.16.33.11): icmp_seq=0 ttl=64 time=0.073 ms
64 bytes from mail.example.com (172.16.33.11): icmp_seq=1 ttl=64 time=0.029 ms

--- mail.example.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.029/0.051/0.073/0.022 ms, pipe 2
[root@mail ~]# ping example.com
PING mail.example.com (172.16.33.11) 56(84) bytes of data.
64 bytes from mail.example.com (172.16.33.11): icmp_seq=0 ttl=64 time=0.064 ms
64 bytes from mail.example.com (172.16.33.11): icmp_seq=1 ttl=64 time=0.031 ms

--- mail.example.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.031/0.047/0.064/0.017 ms, pipe 2
端口测试:
    # telnet mail.nseasy.net 25 (测试25端口)Trying 127.0.0.1...
    Connected to localhost.localdomain (127.0.0.1).
    Escape character is '^]'.
    220 mail.easy.com ESMTP Postfix
    quit
    221 Bye
    Connection closed by foreign host.
    # telnet nseasy.net 110 (测试110端口)Trying 127.0.0.1...
    Connected to localhost.localdomain (127.0.0.1).
    Escape character is '^]'.
    +OK dovecot ready.
    quit
    +OK Logging out
    Connection closed by foreign host.
******************************************************************************************
在main.cf文件中增加以下的代码: (reject_unauth_destination是smtp验证用的)
vi /etc/postfix/main.cf
# restrictions
message_size_limit = 30720000
smtpd_recipient_restrictions = permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_application_name = smtpd
smtpd_sasl_local_domain= ''
smtpd_sasl_auth_enable = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options=noanonymous
******************************************************************************************
注意 iptables 中加上110
至此可以在邮件客户端收发mail
******************************************************************************************
注意事项:
1、Redhat AS4 不带IAMP包了,改为用cyrus-imapd 。使用webmail,必须运行cyrus-imapd 服务。
/etc/rc.d/init.d/cyrus-imapd restart
注意:必须先启动 dovecot 服务,然后才启动 cyrus-imapd 服务,否则会报错。
2、 1. 从FC2版开始就不直接提供POP3服务了,改由dovecot服务来提供。Redhat AS4 的dovecot做pop3服务,配置如下:
编辑 /etc/dovecot.conf :
a 找到 protocols = imap imaps,在该行后加上,并加上protocols = pop3 imap
     protocols = imap imaps
     protocols = pop3 imap
b 找到auth_userdb,auth_passdb,改为如下几行:
     auth_userdb = passwd
     auth_passdb = shadow
重启dovecot服务:/etc/rc.d/init.d/dovecot restart
******************************************************************************************
etc/dovecot.conf:
  ## Dovecot 1.0 configuration file
  protocols = imap imaps
  protocols = pop3 imap    #新增
  imap_listen = [::]
  pop3_listen = [::]
  login_dir = /var/run/dovecot-login
  ##
  ## IMAP login process
  ##
  login = imap
  ##
  ## POP3 login process
  ##
  login = pop3
  mbox_locks = fcntl
  auth = default
  auth_mechanisms = plain
  auth_userdb = passwd    #修改
  auth_passdb = shadow    #修改
  auth_user = root
******************************************************************************************
SASL部分的配置.其实也是很简单.具体如下:
#ln -s /usr/lib/sasl2 /usr/local/lib/sasl2    -------这个连接是必须要做的.因为POSTFIX从/usr/local/lib/sasl2   的路径读取SASL的验证机制  
配置Cyrus-sasl
确定已安装完Cyrus-sasl后,启动该服务: /etc/init.d/saslauthd start     //启动Cyrus-sasl服务。
chkconfig saslauthd on      //把Cyrus-sasl设置为开机自启动。
测试一下是否成功: testsaslauthd –u 系统用户名 –p ‘对应的密码’或/usr/sbin/testsaslauthd –u 系统用户名 –p ‘对应的密码’
如果提示:
0: OK "Success."
则说明已安装成功!
注:Cyrus-sasl的功能就是实现密码验证机制。
#vi /usr/local/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
#/sbin/./service postfix restart
******************************************************************************************
别名:
/etc/postfix/main.cf 中查看 alias_maps = hash:/etc/aliases
vi /etc/aliases 新加user的别名useralias 在最后以行加入
useralias:         user
存盘退出
[root@mail etc]# postalias /etc/aliases
[root@mail etc]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system
******************************************************************************************
共享网域设置 (搭配系统帐户):
vi /etc/hosts
172.16.33.235           mail.netgen.com.cn netgen.com.cn handinweb.com mail.handinweb.com
vi /etc/postfix/main.cf
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, handinweb.com, mail.handinweb.com
[root@mail postfix]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system
******************************************************************************************
检查当前postfix配置是否有问题 文件与目录的拥有权是否正确甚至帮你创建丢失的目录:
[root@mail ~]# postfix check
没有消息就是好消息
******************************************************************************************
日志检查:可以用这个命令查看mail的错误记录
egrep '(reject|warning|error|fatal|panic):' /var/log/maillog
******************************************************************************************
邮件大小尺寸控制: 30M
[root@mail postfix]# pwd
/etc/postfix
[root@mail postfix]# vi main.cf
message_size_limit = 30720000
默认邮箱大小为300M(下面两项都要设置才能设置默认邮箱大小为300M)
mailbox_size_limit = 307200000    //默认的邮箱大小
virtual_mailbox_limit = 30720000 //默认的邮箱大小 
******************************************************************************************
procmail 和 spamassassin 参照aime下的文档
******************************************************************************************
******************************************************************************************
postfix管理
邮件配置好后,会设置五个不同的用途的队列,包括输入(incoming),活动(active),等待(deferred),故障(corrupt),保留(hold),每一个队列在queue_directory参数指定的路径下各有一个专属的子目录。默认的队列目录是/var/spool/postfix,所以你的邮件服务器有类似下面的目录:
/var/spool/postfix/active;
/var/spool/postfix/bounce;
/var/spool/postfix/corrupt;
/var/spool/postfix/deferred/;
/var/spool/postfix/hold;
postfix //管理队列
postqueue -p //显示邮件队列
postqueue -f  //要求postfix立刻投递滞留在队列里的邮件
postsuper -d ALL //删除邮件队列中的所有邮件注:有可能是误删除或删除了不该删除的信,所以谨用此命令。
postquper -h 邮件队列ID(如DBA3F1A9),//执行之后,你会发现,该邮件的queue ID 多了一个感叹号,如果想再次投递该邮件,把-h改成-H即可,postfix就会按照正常顺序再次投递该邮件;
postsuper -r ALL //重新给邮件排队,得到一个新的queue ID,再次投递邮件;
postcat -q 邮件队列号(如DBA3F1A9) //查看该邮件内容;
如果希望postfix在第一次递送邮件失败时就立刻退信,你可以将maximal_queue_lifetime(这个选项参数加在/etc/postfix/main.cf的最后一行就OK了。)设为0和bounce_queue_lifetime = 0即可,默认是5D,(5天);
如果你经常有寄不出去的等等待邮件,或许你应该考虑适度加大maximal_backoff_time(默认是4000秒,本人设为9000秒),让postfix不要浪费太多资源于等待邮件,上数参数都在/etc/postfix/main.cf配置文件里;

access文件的创建
首先在/etc/postfix/main.cf里面的smtpd_client_restrictions = permit_sasl_authenticated后面加,(小写的,)再加上check_client_access hash:/etc/postfix/access,然后service postfix reload(重新加载postfix配置文件)和service postfix restart(重写postfix 服务).
然后再编辑/etc/postfix/access文件,格式和以前sendmail格式相同。最后用postmap /etc/postfix/access命令生成access数据库。即可控制转发等和sendmail相同的效果了。(文件最好加在/etc/postfix/access文件的最后一行加入需要转发或是拒绝的地址或是域名即可)。
如果以WEB方式式收发邮件的话,发送附件大小可以修改:
1、打开/etc/php.ini,修改以下内容:
register_globals=on
max_execution=30 //改为60
memory_limit=8M //改为80M
post_max_size=8M   //改为20M
upload_max_filesize=2M //改为20M
2、打开main.cf,添加一行:message_size_limit=20480000
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics