免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2390 | 回复: 1
打印 上一主题 下一主题

[Web] postfix 内容过滤的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-13 17:20 |只看该作者 |倒序浏览
想做一个统计列表文件,其中记录所有邮件的发送者和接收者,利用postfix的内容过滤功能

我的记录脚本:
  1. vim /usr/src/sms/script

  2. #!/bin/sh
  3. INSPECT_DIR=/usr/src/sms
  4. SENDMAIL="/usr/sbin/sendmail -G -i"
  5. EX_TEMPFAIL=75
  6. EX_UNAVAILABLE=69
  7. trap "rm -f in.$" 0 1 2 3 15
  8. cd $INSPECT_DIR||{
  9.         echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
  10.        
  11. cat >in.$||{
  12.         echo Cannot save mail to file; exit $EX_TEMPFAIL; }
  13.        
  14. $SENDMAIL "$@" <in.$

  15. exit $?

复制代码
在/etc/postfix/master.cf添加
  1. smtp inet        n        -        n        -        -        smtpd
  2.         -o content_filter=filter:
  3. filter unix        -        n        n        -        -        pipe
  4.         flags=Rq user=vmail argv=/usr/src/sms/script -f ${sender} -- ${recipient}
  5.        
复制代码
如果将以上两句去掉,即不进行内容过滤时,此邮件系统工作正常。


当用domain1的域名邮箱向此domail2中发送一封邮件时,/var/log/maillog日志如下(只是其中一段)
  1. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: connect from domain1.com[192.168.0.20]
  2. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: 3DC501376D8: client=domain1.com[192.168.0.20]
  3. Jun 13 16:57:38 domain2 postfix/cleanup[3120]: 3DC501376D8: message-id=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>
  4. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: disconnect from domain1.com[192.168.0.20]
  5. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 3DC501376D8: from=<user1@domain1.com>, size=1579, nrcpt=1 (queue active)
  6. Jun 13 16:57:38 domain2 sendmail[3127]: o5D8vc2X003127: Authentication-Warning: localhost.localdomain: vmail set sender to user1@domain1.com using -f
  7. Jun 13 16:57:38 domain2 sendmail[3127]: o5D8vc2X003127: from=user1@domain1.com, size=1581, class=0, nrcpts=1, msgid=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>, relay=vmail@localhost
  8. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: connect from localhost.localdomain[127.0.0.1]
  9. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: 450F51376DD: client=localhost.localdomain[127.0.0.1]
  10. Jun 13 16:57:38 domain2 postfix/cleanup[3120]: 450F51376DD: message-id=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>
  11. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 450F51376DD: from=<user1@domain1.com>, size=2025, nrcpt=1 (queue active)
  12. Jun 13 16:57:38 domain2 sendmail[3127]: o5D8vc2X003127: to=user2@domain2.com , ctladdr=user1@domain1.com (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31581, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 450F51376DD)
  13. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: disconnect from localhost.localdomain[127.0.0.1]
  14. Jun 13 16:57:38 domain2 postfix/pipe[3122]: 3DC501376D8: to=<user2@domain2.com >, relay=filter, delay=0.09, delays=0.01/0/0/0.07, dsn=2.0.0, status=sent (delivered via filter service)
  15. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 3DC501376D8: removed
  16. Jun 13 16:57:38 domain2 sendmail[3131]: o5D8vc7e003131: Authentication-Warning: localhost.localdomain: vmail set sender to user1@domain1.com using -f
  17. Jun 13 16:57:38 domain2 sendmail[3131]: o5D8vc7e003131: from=user1@domain1.com, size=2020, class=0, nrcpts=1, msgid=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>, relay=vmail@localhost
  18. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: connect from localhost.localdomain[127.0.0.1]
  19. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: 534281376D8: client=localhost.localdomain[127.0.0.1]
  20. Jun 13 16:57:38 domain2 postfix/cleanup[3120]: 534281376D8: message-id=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>
  21. Jun 13 16:57:38 domain2 sendmail[3131]: o5D8vc7e003131: to=user2@domain2.com , ctladdr=user1@domain1.com (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32020, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 534281376D8)
  22. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 534281376D8: from=<user1@domain1.com>, size=2471, nrcpt=1 (queue active)
  23. Jun 13 16:57:38 domain2 sendmail[3135]: o5D8vcrn003135: Authentication-Warning: localhost.localdomain: vmail set sender to user1@domain1.com using -f
  24. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: disconnect from localhost.localdomain[127.0.0.1]
  25. Jun 13 16:57:38 domain2 postfix/pipe[3128]: 450F51376DD: to=<user2@domain2.com >, relay=filter, delay=0.12, delays=0.04/0/0/0.07, dsn=2.0.0, status=sent (delivered via filter service)
  26. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 450F51376DD: removed
  27. Jun 13 16:57:38 domain2 sendmail[3135]: o5D8vcrn003135: from=user1@domain1.com, size=2459, class=0, nrcpts=1, msgid=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>, relay=vmail@localhost
  28. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: connect from localhost.localdomain[127.0.0.1]
  29. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: 6288A1376DD: client=localhost.localdomain[127.0.0.1]
  30. Jun 13 16:57:38 domain2 postfix/cleanup[3120]: 6288A1376DD: message-id=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>
  31. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 6288A1376DD: from=<user1@domain1.com>, size=2917, nrcpt=1 (queue active)
  32. Jun 13 16:57:38 domain2 sendmail[3135]: o5D8vcrn003135: to=user2@domain2.com , ctladdr=user1@domain1.com (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32459, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 6288A1376DD)
  33. Jun 13 16:57:38 domain2 sendmail[3139]: o5D8vcOq003139: Authentication-Warning: localhost.localdomain: vmail set sender to user1@domain1.com using -f
  34. Jun 13 16:57:38 domain2 sendmail[3139]: o5D8vcOq003139: from=user1@domain1.com, size=2898, class=0, nrcpts=1, msgid=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>, relay=vmail@localhost
  35. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: disconnect from localhost.localdomain[127.0.0.1]
  36. Jun 13 16:57:38 domain2 postfix/pipe[3122]: 534281376D8: to=<user2@domain2.com >, relay=filter, delay=0.13, delays=0.04/0/0/0.09, dsn=2.0.0, status=sent (delivered via filter service)
  37. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 534281376D8: removed
  38. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: connect from localhost.localdomain[127.0.0.1]
  39. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: 739841376D8: client=localhost.localdomain[127.0.0.1]
  40. Jun 13 16:57:38 domain2 postfix/cleanup[3120]: 739841376D8: message-id=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>
  41. Jun 13 16:57:38 domain2 sendmail[3139]: o5D8vcOq003139: to=user2@domain2.com , ctladdr=user1@domain1.com (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32898, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 739841376D8)
  42. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 739841376D8: from=<user1@domain1.com>, size=3363, nrcpt=1 (queue active)
  43. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: disconnect from localhost.localdomain[127.0.0.1]
  44. Jun 13 16:57:38 domain2 postfix/pipe[3128]: 6288A1376DD: to=<user2@domain2.com >, relay=filter, delay=0.12, delays=0.04/0/0/0.08, dsn=2.0.0, status=sent (delivered via filter service)
  45. Jun 13 16:57:38 domain2 postfix/qmgr[3105]: 6288A1376DD: removed
  46. Jun 13 16:57:38 domain2 sendmail[3143]: o5D8vcNn003143: Authentication-Warning: localhost.localdomain: vmail set sender to user1@domain1.com using -f
  47. Jun 13 16:57:38 domain2 sendmail[3143]: o5D8vcNn003143: from=user1@domain1.com, size=3337, class=0, nrcpts=1, msgid=<52768.192.168.0.194.1276419012.squirrel@mail.domain1.com>, relay=vmail@localhost
  48. Jun 13 16:57:38 domain2 postfix/smtpd[3114]: connect from localhost.localdomain[127.0.0.1]
复制代码
并且postqueue队列中总有一个排队邮件,如下:
  1. [root@localhost sms]# postqueue -p
  2. -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
  3. 98CDE1376DD* 2616687 Sun Jun 13 17:08:13  MAILER-DAEMON@localhost.localdomain
  4.                                          MAILER-DAEMON@localhost.localdomain

  5. -- 2556 Kbytes in 1 Request.
复制代码
在domail1上面还会受到退信:
  1. This is the mail system at host mail.domain2.com.

  2. I'm sorry to have to inform you that your message could not
  3. be delivered to one or more recipients. It's attached below.

  4. For further assistance, please send mail to <postmaster>

  5. If you do so, please include this problem report. You can
  6. delete your own text from the attached returned message.

  7.                    The mail system

  8. <user2@domain2.com>: service unavailable

  9. Reporting-MTA: dns; mail.domain2.com
  10. X-Postfix-Queue-ID: CF6FA1376D8
  11. X-Postfix-Sender: rfc822; user1@domain1.com
  12. Arrival-Date: Sun, 13 Jun 2010 16:57:38 +0800 (CST)

  13. Final-Recipient: rfc822; user2@domain2.com
  14. Original-Recipient: rfc822;user2@domain2.com
  15. Action: failed
  16. Status: 5.3.0
  17. Diagnostic-Code: x-unix; service unavailable

  18. ------------------------------------------------------------
  19. From:  user1@domain1.com
  20. To:  user2@domain2.com
  21. Subject:  444
  22. Date:  Sun13 Jun 2010 16:50:12 +0800 (CST)

  23. 4444

  24. ------------------------------------------------------------
复制代码
请各位帮忙分析分析,我已经研究了好几天了,头都快炸了,可还是没有成功,多谢了

论坛徽章:
0
2 [报告]
发表于 2010-06-16 11:39 |只看该作者
自己顶一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP