常见问题集

Postfix

Q: postfix中我如何让我的配置生效?
Q: postfix中我如何刷新邮件队列?
Q: 我如何设置postfix的队列延迟?
Q: 如何禁止postfix对客户端IP作反向域名解析?
Q: 有什么工具可以帮忙我分析我的postfix日志吗?
Q: 投递邮件~/Maildir/下出现,example.org/Maildir/
Q: 删除邮件队列
Q: 卸载Postfix
Q: NOQUEUE: reject
Q: /var/mail 空间不足
Q: 拒收附件括展名为.exe|.com|.bat|...的邮件
Q:   

Q: postfix中我如何让我的配置生效?

A: 以root用户身份 postfix reload,postfix 并没用restart笔者也不建议你使用restart,reboot,restart这是一个坏习惯

Q: postfix中我如何刷新邮件队列?

A: 以root用户身份 postfix flush

Q: 我如何设置postfix的队列延迟?

A: 你可以在postfix的主要配置文件/etc/postifx/main.cf中修改下列参数:

queue_run_delay (默认值 1000秒) 设置多长时间队列管理进程去扫描无法投递的邮件

Maximal_queue_lifetime (默认值 5天) 设置邮件在队列里的最长时间

Minimal_backoff_time (默认值 1000秒) 在这个时间内,邮件不能够被锁定

Maximal_backoff_time (默认值 4000秒) 在这个时间之后,如果邮件仍然没有被投递,就认为是无法投递

qmgr_message_recipient_limit (默认值 1000) |

Q: 如何禁止postfix对客户端IP作反向域名解析?

A: 以root用户身份登录 postconf -e disable_client_dns_lookup = 1 postfix reload

Q: 有什么工具可以帮忙我分析我的postfix日志吗?

A: James S. Seymour用perl写了一个叫pflogsumm.pl的脚本,可以到这里下载:http://jimsun.linxnet.com/postfix_contrib.html,然后可以在crontab中添加下面的内容: 0 2 * * * /path/to/pflogsumm.pl -d today /var/log/maillog | mail -s "Mail Report" [email protected] 定时把分析报告寄给你,其它的一些使用参数可以看pflogsumm.pl里的信息。

Q: 投递邮件~/Maildir/下出现,example.org/Maildir/

A: 这个问题是因为出现两个同名邮件地址

Q: 删除邮件队列

A: mailq | tail +2 | awk 'BEGIN { RS = "" } / chen@example\.org$/ { print $1 }' | tr -d '*!' | postsuper -d -

[root@linuxas3 root]# vi mailqueue
#!/bin/bash
# [email protected]
queue=$1
# echo ${queue}
DELETE="mailq | tail +2 | awk  'BEGIN { RS = \"\" } /${queue}$/ { print \$1 }' | tr -d '*!' | postsuper -d -"
echo ${DELETE} > queue
chmod 755 queue
./queue
[root@linuxas3 root]# chmod 755 mailqueue
[root@linuxas3 root]# ./mailqueue chen@example\\.org
mailq | tail +2 | awk 'BEGIN { RS = "" } /chen@example\.org$/ { print $1 }' | tr -d '*!' | postsuper -d -
postsuper: 9A427225DEE: removed
postsuper: 97CB6225D8E: removed
postsuper: 980B0225DF0: removed
postsuper: DAF67225D8B: removed
postsuper: A5303225D90: removed
postsuper: 2B285225DED: removed
postsuper: 761EB225D8A: removed
postsuper: 5EC8D225D86: removed
postsuper: C6AE2225DEC: removed
postsuper: 0C35C225DF1: removed
postsuper: E4361225DEA: removed
postsuper: 36717225D8D: removed
postsuper: 30E0D225DEF: removed
postsuper: BD2B2225DF3: removed
postsuper: Deleted: 14 messages
		

Q: 卸载Postfix

A: 复制下面命令粘贴到CLI上即可。

postfix stop
rm -rf /usr/libexec/postfix/bounce
rm -rf /usr/libexec/postfix/cleanup
rm -rf /usr/libexec/postfix/error
rm -rf /usr/libexec/postfix/flush
rm -rf /usr/libexec/postfix/lmtp
rm -rf /usr/libexec/postfix/local
rm -rf /usr/libexec/postfix/master
rm -rf /usr/libexec/postfix/nqmgr
rm -rf /usr/libexec/postfix/pickup
rm -rf /usr/libexec/postfix/pipe
rm -rf /usr/libexec/postfix/proxymap
rm -rf /usr/libexec/postfix/qmgr
rm -rf /usr/libexec/postfix/qmqpd
rm -rf /usr/libexec/postfix/showq
rm -rf /usr/libexec/postfix/smtp
rm -rf /usr/libexec/postfix/smtpd
rm -rf /usr/libexec/postfix/spawn
rm -rf /usr/libexec/postfix/trivial-rewrite
rm -rf /usr/libexec/postfix/virtual
rm -rf /usr/sbin/postalias
rm -rf /usr/sbin/postcat
rm -rf /usr/sbin/postconf
rm -rf /usr/sbin/postfix
rm -rf /usr/sbin/postkick
rm -rf /usr/sbin/postlock
rm -rf /usr/sbin/postlog
rm -rf /usr/sbin/postmap
rm -rf /usr/sbin/postsuper
rm -rf /usr/sbin/postdrop
rm -rf /usr/sbin/postqueue
rm -rf /usr/sbin/sendmail
rm -rf /usr/bin/newaliases
rm -rf /usr/bin/mailq
rm -rf /etc/postfix/LICENSE
rm -rf /etc/postfix/access
rm -rf /etc/postfix/aliases
rm -rf /etc/postfix/canonical
rm -rf /etc/postfix/main.cf
rm -rf /etc/postfix/main.cf.default
rm -rf /etc/postfix/master.cf
rm -rf /etc/postfix/pcre_table
rm -rf /etc/postfix/postfix-files
rm -rf /etc/postfix/regexp_table
rm -rf /etc/postfix/relocated
rm -rf /etc/postfix/transport
rm -rf /etc/postfix/virtual
rm -rf /etc/postfix/postfix-script
rm -rf /etc/postfix/post-install
rm -rf /usr/local/man/man1/mailq.1
rm -rf /usr/local/man/man1/newaliases.1
rm -rf /usr/local/man/man1/postalias.1
rm -rf /usr/local/man/man1/postcat.1
rm -rf /usr/local/man/man1/postconf.1
rm -rf /usr/local/man/man1/postdrop.1
rm -rf /usr/local/man/man1/postfix.1
rm -rf /usr/local/man/man1/postkick.1
rm -rf /usr/local/man/man1/postlock.1
rm -rf /usr/local/man/man1/postlog.1
rm -rf /usr/local/man/man1/postmap.1
rm -rf /usr/local/man/man1/postqueue.1
rm -rf /usr/local/man/man1/postsuper.1
rm -rf /usr/local/man/man1/sendmail.1
rm -rf /usr/local/man/man5/access.5
rm -rf /usr/local/man/man5/aliases.5
rm -rf /usr/local/man/man5/canonical.5
rm -rf /usr/local/man/man5/pcre_table.5
rm -rf /usr/local/man/man5/regexp_table.5
rm -rf /usr/local/man/man5/relocated.5
rm -rf /usr/local/man/man5/transport.5
rm -rf /usr/local/man/man5/virtual.5
rm -rf /usr/local/man/man8/bounce.8
rm -rf /usr/local/man/man8/cleanup.8
rm -rf /usr/local/man/man8/defer.8
rm -rf /usr/local/man/man8/error.8
rm -rf /usr/local/man/man8/flush.8
rm -rf /usr/local/man/man8/lmtp.8
rm -rf /usr/local/man/man8/local.8
rm -rf /usr/local/man/man8/master.8
rm -rf /usr/local/man/man8/nqmgr.8
rm -rf /usr/local/man/man8/pickup.8
rm -rf /usr/local/man/man8/pipe.8
rm -rf /usr/local/man/man8/proxymap.8
rm -rf /usr/local/man/man8/qmgr.8
rm -rf /usr/local/man/man8/qmqpd.8
rm -rf /usr/local/man/man8/showq.8
rm -rf /usr/local/man/man8/smtp.8
rm -rf /usr/local/man/man8/smtpd.8
rm -rf /usr/local/man/man8/spawn.8
rm -rf /usr/local/man/man8/trivial-rewrite.8
rm -rf /usr/local/man/man8/virtual.8
rm -rf /etc/postfix/sample-aliases.cf
rm -rf /etc/postfix/sample-auth.cf
rm -rf /etc/postfix/sample-canonical.cf
rm -rf /etc/postfix/sample-compatibility.cf
rm -rf /etc/postfix/sample-debug.cf
rm -rf /etc/postfix/sample-filter.cf
rm -rf /etc/postfix/sample-flush.cf
rm -rf /etc/postfix/sample-ldap.cf
rm -rf /etc/postfix/sample-lmtp.cf
rm -rf /etc/postfix/sample-local.cf
rm -rf /etc/postfix/sample-mime.cf
rm -rf /etc/postfix/sample-misc.cf
rm -rf /etc/postfix/sample-pcre-access.cf
rm -rf /etc/postfix/sample-pcre-body.cf
rm -rf /etc/postfix/sample-pcre-header.cf
rm -rf /etc/postfix/sample-qmqpd.cf
rm -rf /etc/postfix/sample-rate.cf
rm -rf /etc/postfix/sample-regexp-access.cf
rm -rf /etc/postfix/sample-regexp-body.cf
rm -rf /etc/postfix/sample-regexp-header.cf
rm -rf /etc/postfix/sample-relocated.cf
rm -rf /etc/postfix/sample-resource.cf
rm -rf /etc/postfix/sample-rewrite.cf
rm -rf /etc/postfix/sample-smtp.cf
rm -rf /etc/postfix/sample-smtpd.cf
rm -rf /etc/postfix/sample-transport.cf
rm -rf /etc/postfix/sample-virtual.cf
rm -rf /etc/postfix
rm -rf /usr/libexec/postfix
rm -rf /var/spool/postfix
				

Q: NOQUEUE: reject

Sep 17 23:18:44 localhost postfix/smtpd[12087]: connect from unknown[192.168.0.254]
Sep 17 23:18:44 localhost postfix/smtpd[12087]: NOQUEUE: reject: RCPT from unknown[192.168.0.254]: 550 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<netkiller>
Sep 17 23:18:54 localhost postfix/smtpd[12087]: lost connection after RCPT from unknown[192.168.0.254]
Sep 17 23:18:54 localhost postfix/smtpd[12087]: disconnect from unknown[192.168.0.254]
			

A: main.cf中没有设置local_recipient_maps =

Q: /var/mail 空间不足

A: mount --bind /var/mail/ /home/mail/

[root@linux home]# mkdir -m755 mail
[root@linux home]# mount --bind /var/mail/ /home/mail/
[root@linux home]# ls mail/
axia  chen  crm  cvs  cvsroot  example.net  guest  ming  postfix  root  sales  svnroot  test
[root@linux home]# mount
/dev/hda8 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/hda1 on /boot type ext3 (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda2 on /home type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/hda7 on /tmp type ext3 (rw)
/dev/hda9 on /u01 type ext3 (rw)
/dev/hda5 on /usr type ext3 (rw)
/dev/hda3 on /var type ext3 (rw)
/var/mail on /home/mail type none (rw,bind)
[root@linux home]# umount /var/mail
[root@linux home]# mount
/dev/hda8 on / type ext3 (rw)
none on /proc type proc (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/hda1 on /boot type ext3 (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/hda2 on /home type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/hda7 on /tmp type ext3 (rw)
/dev/hda9 on /u01 type ext3 (rw)
/dev/hda5 on /usr type ext3 (rw)
/dev/hda3 on /var type ext3 (rw)
[root@linux home]#

				

Q: 拒收附件括展名为.exe|.com|.bat|...的邮件

A: 如果你安装了amavis它可以完成拒收.默认是弹回.如果你不想安装它,可以使用postfix的mime_header_checks

debian:~# postconf -e 'mime_header_checks=pcre:/etc/postfix/body_checks'
				

创建body_checks文件内容如下:

debian:~# vi /etc/postfix/body_checks
/^((Content-(Disposition: attachment;|Type:).*|\ +)| *)(file)?name\ *=\ *"?.*\.(lnk|asd|hlp|ocx|reg|bat|c[ho]m|cmd|exe|dll|vxd|pif|scr|hta|jse?|sh[mbs]|vb[esx]|ws[fh]|wmf)"?\ *$/      REJECT  attachment type not allowed
				

reload

debian:~# /etc/init.d/postfix reload
Reloading Postfix configuration...done.
debian:~#
				

Q:   

A: