postqueue和postsuper进行以下操作
显示邮件列表:postqueue -p 相当与sendmail的mailq
删除邮件:postsuper -d 07517E00E5 #07517E00E5为queue id,
删除所有邮件:postsuper -d ALL #删除所有(慎用)
保留邮件:postsuper -h 98F76DFB90
移回保留邮件到原来的队列:postsuper -H 98F76DFB90 #此时qmgr就会依照平常的调度来投递邮件
重新排列:postsuper -r ALL #因配置问题耽搁了正常的邮件投递,使用此法重新投递。会重新生成新的队列号
显示邮件内容:postcat -q D2806DFAA2
清空邮件:postqueue -f #要求postfix立刻投递滞留在队列里面的邮件操作,称为清空邮件
######################################################################################################################
root@mail:/home/dfjsb# ls /var/spool/postfix/ -al
total 84
drwxr-xr-x 21 root root 4096 2011-08-05 10:32 .
drwxr-xr-x 5 root root 4096 2011-08-05 10:10 ..
drwx------ 2 postfix root 4096 2011-08-08 16:46 active #2、incoming到此目录,出错是从此目录移动到deferred
drwx------ 2 postfix root 4096 2011-08-05 10:10 bounce
drwx------ 2 postfix root 4096 2011-08-05 10:10 corrupt #此队列用于存放损坏的邮件,此队列出现邮件通常是系统或硬件出问题了
drwx------ 10 postfix root 4096 2011-08-08 16:40 defer
drwx------ 10 postfix root 4096 2011-08-08 16:40 deferred
drwxr-xr-x 2 root root 4096 2011-08-08 10:23 dev
drwxr-xr-x 3 root root 4096 2011-08-08 15:22 etc
drwx------ 2 postfix root 4096 2011-08-05 10:10 flush
drwx------ 2 postfix root 4096 2011-08-08 16:21 hold #postsuper -h 98F76DFB90
drwx------ 2 postfix root 4096 2011-08-08 16:40 incoming #1、postdrop或smtpd传递到这个目录
drwxr-xr-x 2 root root 4096 2011-08-08 15:22 lib
drwx-wx--T 2 postfix postdrop 4096 2011-08-08 16:40 maildrop #除了user可以创建文件外,user,group可以执行可写数据到这路目录下面的文件里面
drwxr-xr-x 2 root root 4096 2011-08-05 13:06 pid
drwx------ 2 postfix root 4096 2011-08-08 15:22 private
drwx--s--- 2 postfix postdrop 4096 2011-08-08 15:22 public
drwx------ 2 postfix root 4096 2011-08-05 10:10 saved
drwx------ 2 postfix root 4096 2011-08-05 10:10 trace
drwxr-xr-x 3 root root 4096 2011-08-05 10:10 usr
drwxr-xr-x 3 root root 4096 2011-08-05 10:32 var
######################################################################################################################
以下为模拟邮件无法正常投递时,如何查询错误和排除错误
root@mail:/home/dfjsb# postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
16AC1E047C 627 Mon Aug 8 16:11:42 jj@extmail.org
(Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again)
zyqojj@gmail.com
-- 1 Kbytes in 1 Request.
#以上有一封信无法正常投递,没有查找到域名,说明可能是DNS的解析的问题(ping 8.8.4.4)
root@mail:/home/dfjsb# ll /var/spool/postfix/deferred/1/
total 12
drwx------ 2 postfix postfix 4096 2011-08-08 16:15 ./
drwx------ 7 postfix root 4096 2011-08-08 16:11 ../
-rwx------ 1 postfix postfix 1229 2011-08-08 16:20 16AC1E047C*
root@mail:/home/dfjsb# postsuper -h 16AC1E047C
postsuper: 16AC1E047C: placed on hold
postsuper: Placed on hold: 1 message
root@mail:/home/dfjsb#
root@mail:/home/dfjsb# ll /var/spool/postfix/hold/
total 12
drwx------ 2 postfix root 4096 2011-08-08 16:20 ./
drwxr-xr-x 21 root root 4096 2011-08-05 10:32 ../
-rwx------ 1 postfix postfix 1229 2011-08-08 16:20 16AC1E047C*
root@mail:/home/dfjsb# postsuper -H 16AC1E047C
postsuper: 16AC1E047C: released from hold
postsuper: Released from hold: 1 message
#日志如下
root@mail:/home/vmail/extmail.org/jj/Maildir# tail -f /var/log/mail.log
Aug 8 16:11:42 mail postfix/smtpd[2127]: 16AC1E047C: client=localhost[127.0.0.1]
Aug 8 16:11:42 mail postfix/cleanup[2131]: 16AC1E047C: message-id=<20110808081142.16AC1E047C@mail.jmail.com>
Aug 8 16:11:42 mail postfix/qmgr[2076]: 16AC1E047C: from=
, size=627, nrcpt=1 (queue active)
Aug 8 16:11:42 mail postfix/smtpd[2127]: disconnect from localhost[127.0.0.1]
Aug 8 16:11:42 mail postfix/smtp[2132]: 16AC1E047C: to=, relay=none, delay=0.04, delays=0.04/0/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again) #发送邮件失败
Aug 8 16:13:39 mail postfix/postsuper[2141]: 37FBBE03CA: removed
Aug 8 16:13:39 mail postfix/postsuper[2141]: Deleted: 1 message
Aug 8 16:15:28 mail postfix/qmgr[2076]: 16AC1E047C: from=, size=627, nrcpt=1 (queue active)
Aug 8 16:15:28 mail postfix/smtp[2151]: 16AC1E047C: to=, relay=none, delay=226, delays=226/0.02/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again)
Aug 8 16:18:31 mail postfix/master[2073]: reload -- version 2.7.0, configuration /etc/postfix
Aug 8 16:20:27 mail postfix/postsuper[2242]: 16AC1E047C: placed on hold #postsuper -h 16AC1E047C
Aug 8 16:20:27 mail postfix/postsuper[2242]: Placed on hold: 1 message
Aug 8 16:21:23 mail postfix/postsuper[2246]: 16AC1E047C: released from hold #postsuper -H 16AC1E047C
Aug 8 16:21:23 mail postfix/postsuper[2246]: Released from hold: 1 message
Aug 8 16:22:04 mail postfix/postsuper[2248]: 16AC1E047C: requeued #postsuper -r 16AC1E047C
Aug 8 16:22:04 mail postfix/postsuper[2248]: Requeued: 1 message
Aug 8 16:22:31 mail postfix/smtp[2251]: 48DA9DFC94: to=, relay=none, delay=649, delays=649/0.01/0/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again) #网络通了,因为dns配置错误导致无法正常发送邮件
Aug 8 16:22:44 mail postfix/qmgr[2234]: 48DA9DFC94: from=, size=753, nrcpt=1 (queue active)
Aug 8 16:30:45 mail postfix/master[2073]: reload -- version 2.7.0, configuration /etc/postfix
Aug 8 16:31:39 mail postfix/qmgr[2307]: 48DA9DFC94: from=, size=753, nrcpt=1 (queue active) #postqueue -f
Aug 8 16:31:49 mail postfix/smtp[2320]: 48DA9DFC94: to=, relay=gmail-smtp-in.l.google.com[74.125.127.27]:25, delay=1208, delays=1198/0.02/3.8/6.3, dsn=2.0.0, status=sent (250 2.0.0 OK 1312792305 o3si14585210wfd.26)
Aug 8 16:31:49 mail postfix/qmgr[2307]: 48DA9DFC94: removed #DNS配置正确后,邮件发送成功,自动删除队列里的邮件
root@mail:/home/dfjsb# ll /var/spool/postfix/deferred/D/
total 8
drwx------ 2 postfix postfix 4096 2011-08-05 14:06 ./
drwx------ 8 postfix root 4096 2011-08-08 16:22 ../
#总结:
邮件发送失败通常需要以下操作:
tail -f /var/log/mail.log #查看日志,确定失败原因
postqueue -p #查看哪些邮件投递失败
postsuper -r 16AC1E047C #重新排列此邮件,会生成新的队列ID号
postqueue -f #要求postfix立刻投递滞留在队列里面的邮件操作,称为清空邮件 #有滞留邮件时,建议使用此命令
转载请标明出处:http://xishi.blog.chinaunix.net