Posted By


lubke2005 on 07/29/09

Tagged


Statistics


Viewed 278 times
Favorited by 1 user(s)

Bouncemanagement


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. /*~ phpmailer-bmh_rules.php
  3. .---------------------------------------------------------------------------.
  4. | Software: PHPMailer-BMH (Bounce Mail Handler) |
  5. | Version: 5.0.0rc1 |
  6. | Contact: [email protected] |
  7. | Info: http://phpmailer.codeworxtech.com |
  8. | ------------------------------------------------------------------------- |
  9. | Author: Andy Prevost [email protected] (admin) |
  10. | Copyright (c) 2002-2009, Andy Prevost. All Rights Reserved. |
  11. | ------------------------------------------------------------------------- |
  12. | License: Distributed under the General Public License (GPL) |
  13. | (http://www.gnu.org/licenses/gpl.html) |
  14. | This program is distributed in the hope that it will be useful - WITHOUT |
  15. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
  16. | FITNESS FOR A PARTICULAR PURPOSE. |
  17. | ------------------------------------------------------------------------- |
  18. | This is a update of the original Bounce Mail Handler script |
  19. | http://sourceforge.net/projects/bmh/ |
  20. | The script has been renamed from Bounce Mail Handler to PHPMailer-BMH |
  21. | ------------------------------------------------------------------------- |
  22. | We offer a number of paid services: |
  23. | - Web Hosting on highly optimized fast and secure servers |
  24. | - Technology Consulting |
  25. | - Oursourcing (highly qualified programmers and graphic designers) |
  26. '---------------------------------------------------------------------------'
  27. Last updated: January 21 2009 13:49 EST
  28.  
  29. /**
  30. * next rule number (BODY): 0238 <br />
  31. * default category: unrecognized: <br />
  32. * default rule no.: 0000 <br />
  33. */
  34.  
  35. global $rule_categories;
  36. $rule_categories = array(
  37. 'antispam' => array('remove'=>0,'bounce_type'=>'blocked' )
  38. ,'autoreply' => array('remove'=>0,'bounce_type'=>'autoreply')
  39. ,'concurrent' => array('remove'=>0,'bounce_type'=>'soft' )
  40. ,'content_reject' => array('remove'=>0,'bounce_type'=>'soft' )
  41. ,'command_reject' => array('remove'=>1,'bounce_type'=>'hard' )
  42. ,'internal_error' => array('remove'=>0,'bounce_type'=>'temporary')
  43. ,'defer' => array('remove'=>0,'bounce_type'=>'soft' )
  44. ,'delayed' => array('remove'=>0,'bounce_type'=>'temporary')
  45. ,'dns_loop' => array('remove'=>1,'bounce_type'=>'hard' )
  46. ,'dns_unknown' => array('remove'=>1,'bounce_type'=>'hard' )
  47. ,'full' => array('remove'=>0,'bounce_type'=>'soft' )
  48. ,'inactive' => array('remove'=>1,'bounce_type'=>'hard' )
  49. ,'latin_only' => array('remove'=>0,'bounce_type'=>'soft' )
  50. ,'other' => array('remove'=>1,'bounce_type'=>'generic' )
  51. ,'oversize' => array('remove'=>0,'bounce_type'=>'soft' )
  52. ,'outofoffice' => array('remove'=>0,'bounce_type'=>'soft' )
  53. ,'unknown' => array('remove'=>1,'bounce_type'=>'hard' )
  54. ,'unrecognized' => array('remove'=>0,'bounce_type'=>false, )
  55. ,'user_reject' => array('remove'=>1,'bounce_type'=>'hard' )
  56. ,'warning' => array('remove'=>0,'bounce_type'=>'soft' )
  57. );
  58.  
  59. /*
  60.  * var for new line ending
  61.  */
  62. $bmh_newline = "<br />\n";
  63.  
  64. /**
  65.  * Defined bounce parsing rules for non-standard DSN
  66.  * @param string $body body of the email
  67.  * @param string $structure message structure
  68.  * @param boolean $debug_mode show debug info. or not
  69.  * @return array $result an array include the following fields: 'email', 'bounce_type','remove','rule_no','rule_cat'
  70.  * if we could NOT detect the type of bounce, return rule_no = '0000'
  71.  */
  72. function bmhBodyRules($body,$structure,$debug_mode=false) {
  73. // initialize the result array
  74. $result = array(
  75. 'email' => ''
  76. ,'bounce_type' => false
  77. ,'remove' => 0
  78. ,'rule_cat' => 'unrecognized'
  79. ,'rule_no' => '0000'
  80. );
  81.  
  82. // ======== rule =========
  83. if (false) {
  84. }
  85.  
  86. /*
  87.   * rule: mailbox unknown;
  88.   * sample:
  89.   * no such address here
  90.   */
  91. elseif (preg_match ("/(\S+@\S+\w).*\n?.*no such address here/i",$body,$match)) {
  92. $result['rule_cat'] = 'unknown';
  93. $result['rule_no'] = '0237';
  94. $result['email'] = $match[1];
  95. }
  96.  
  97. /*
  98.   * 111.111.111.111 does not like recipient.
  99.   * Remote host said: 550 User unknown
  100.   */
  101. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*\n?.*user unknown/i",$body,$match)) {
  102. $result['rule_cat'] = 'unknown';
  103. $result['rule_no'] = '0236';
  104. $result['email'] = $match[1];
  105. }
  106.  
  107. /*
  108.   * rule: mailbox unknown;
  109.   * sample:
  110.   * Sorry, no mailbox here by that name. vpopmail (#5.1.1)
  111.   */
  112. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*no mailbox/i",$body,$match)) {
  113. $result['rule_cat'] = 'unknown';
  114. $result['rule_no'] = '0157';
  115. $result['email'] = $match[1];
  116. }
  117.  
  118. /*
  119.   * rule: mailbox unknown;
  120.   * sample:
  121.   * local: Sorry, can't find user's mailbox. (#5.1.1)<br>
  122.   */
  123. elseif (preg_match ("/(\S+@\S+\w)<br>.*\n?.*\n?.*can't find.*mailbox/i",$body,$match)) {
  124. $result['rule_cat'] = 'unknown';
  125. $result['rule_no'] = '0164';
  126. $result['email'] = $match[1];
  127. }
  128.  
  129. /*
  130.   * rule: mailbox unknown;
  131.   * sample:
  132.   * ##########################################################
  133.   * # This is an automated response from a mail delivery #
  134.   * # program. Your message could not be delivered to #
  135.   * # the following address: #
  136.   * # #
  137.   * # "|/usr/local/bin/mailfilt -u #dkms" #
  138.   * # (reason: Can't create output) #
  139.   * # (expanded from: <[email protected]>) #
  140.   * # #
  141.   */
  142. elseif (preg_match ("/Can't create output.*\n?.*<(\S+@\S+\w)>/i",$body,$match)) {
  143. $result['rule_cat'] = 'unknown';
  144. $result['rule_no'] = '0169';
  145. $result['email'] = $match[1];
  146. }
  147.  
  148. /*
  149.   * rule: mailbox unknown;
  150.   * sample:
  151.   * ????????????????:
  152.   * [email protected] : ????, ?????.
  153.   */
  154. elseif (preg_match ("/(\S+@\S+\w).*=D5=CA=BA=C5=B2=BB=B4=E6=D4=DA/i",$body,$match)) {
  155. $result['rule_cat'] = 'unknown';
  156. $result['rule_no'] = '0174';
  157. $result['email'] = $match[1];
  158. }
  159.  
  160. /*
  161.   * rule: mailbox unknown;
  162.   * sample:
  163.   * Unrouteable address
  164.   */
  165. elseif (preg_match ("/(\S+@\S+\w).*\n?.*Unrouteable address/i",$body,$match)) {
  166. $result['rule_cat'] = 'unknown';
  167. $result['rule_no'] = '0179';
  168. $result['email'] = $match[1];
  169. }
  170.  
  171. /*
  172.   * rule: mailbox unknow;
  173.   * sample:
  174.   * Delivery to the following recipients failed.
  175.   */
  176. elseif (preg_match ("/delivery[^\n\r]+failed\S*\s+(\S+@\S+\w)\s/is",$body,$match)) {
  177. $result['rule_cat'] = 'unknown';
  178. $result['rule_no'] = '0013';
  179. $result['email'] = $match[1];
  180. }
  181.  
  182. /*
  183.   * rule: mailbox unknow;
  184.   * sample:
  185.   * A message that you sent could not be delivered to one or more of its^M
  186.   * recipients. This is a permanent error. The following address(es) failed:^M
  187.   * ^M
  188.   * unknown local-part "xxxxx" in domain "yourdomain.com"^M
  189.   */
  190. elseif (preg_match ("/(\S+@\S+\w).*\n?.*unknown local-part/i",$body,$match)) {
  191. $result['rule_cat'] = 'unknown';
  192. $result['rule_no'] = '0232';
  193. $result['email'] = $match[1];
  194. }
  195.  
  196. /*
  197.   * rule: mailbox unknow;
  198.   * sample:
  199.   * 111.111.111.11 does not like recipient.^M
  200.   * Remote host said: 550 Invalid recipient: <[email protected]>^M
  201.   */
  202. elseif (preg_match ("/Invalid.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/i",$body,$match)) {
  203. $result['rule_cat'] = 'unknown';
  204. $result['rule_no'] = '0233';
  205. $result['email'] = $match[1];
  206. }
  207.  
  208. /*
  209.   * rule: mailbox unknow;
  210.   * sample:
  211.   * Sent >>> RCPT TO: <[email protected]>^M
  212.   * Received <<< 550 [email protected]... No such user^M
  213.   * ^M
  214.   * Could not deliver mail to this user.^M
  215.   * ***************** End of message ***************^M
  216.   */
  217. elseif (preg_match ("/\s(\S+@\S+\w).*No such.*(?:alias|account|recipient|address|email|mailbox|user)>/i",$body,$match)) {
  218. $result['rule_cat'] = 'unknown';
  219. $result['rule_no'] = '0234';
  220. $result['email'] = $match[1];
  221. }
  222.  
  223. /*
  224.   * rule: mailbox unknow;
  225.   * sample:
  226.   * This address no longer accepts mail.
  227.   */
  228. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*(?:alias|account|recipient|address|email|mailbox|user).*no.*accept.*mail>/i",$body,$match)) {
  229. $result['rule_cat'] = 'unknown';
  230. $result['rule_no'] = '0235';
  231. $result['email'] = $match[1];
  232. }
  233.  
  234. /*
  235.   * rule: full
  236.   * sample 1:
  237.   * This account is over quota and unable to receive mail.
  238.   * sample 2:
  239.   * Warning: undefined mail delivery mode: normal (ignored).
  240.   * The users mailfolder is over the allowed quota (size). (#5.2.2)
  241.   */
  242. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*\n?.*over.*quota/i",$body,$match)) {
  243. $result['rule_cat'] = 'full';
  244. $result['rule_no'] = '0182';
  245. $result['email'] = $match[1];
  246. }
  247.  
  248. /*
  249.   * rule: mailbox full;
  250.   * sample:
  251.   * ----- Transcript of session follows -----
  252.   * mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
  253.   * 554 <[email protected]>... Service unavailable
  254.   */
  255. elseif (preg_match ("/quota exceeded.*\n?.*<(\S+@\S+\w)>/i",$body,$match)) {
  256. $result['rule_cat'] = 'full';
  257. $result['rule_no'] = '0126';
  258. $result['email'] = $match[1];
  259. }
  260.  
  261. /*
  262.   * rule: mailbox full;
  263.   * sample:
  264.   * Hi. This is the qmail-send program at 263.domain.com.
  265.   * - User disk quota exceeded. (#4.3.0)
  266.   */
  267. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*quota exceeded/i",$body,$match)) {
  268. $result['rule_cat'] = 'full';
  269. $result['rule_no'] = '0158';
  270. $result['email'] = $match[1];
  271. }
  272.  
  273. /*
  274.   * rule: mailbox full;
  275.   * sample:
  276.   * mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):
  277.   */
  278. elseif (preg_match ("/\s(\S+@\S+\w)\s.*\n?.*mailbox.*full/i",$body,$match)) {
  279. $result['rule_cat'] = 'full';
  280. $result['rule_no'] = '0166';
  281. $result['email'] = $match[1];
  282. }
  283.  
  284. /*
  285.   * rule: mailbox full;
  286.   * sample:
  287.   * The message to [email protected] is bounced because : Quota exceed the hard limit
  288.   */
  289. elseif (preg_match ("/The message to (\S+@\S+\w)\s.*bounce.*Quota exceed/i",$body,$match)) {
  290. $result['rule_cat'] = 'full';
  291. $result['rule_no'] = '0168';
  292. $result['email'] = $match[1];
  293. }
  294.  
  295. /*
  296.   * rule: inactive
  297.   * sample:
  298.   * 553 user is inactive (eyou mta)
  299.   */
  300. elseif (preg_match ("/(\S+@\S+\w)<br>.*\n?.*\n?.*user is inactive/i",$body,$match)) {
  301. $result['rule_cat'] = 'inactive';
  302. $result['rule_no'] = '0171';
  303. $result['email'] = $match[1];
  304. }
  305.  
  306. /*
  307.   * rule: inactive
  308.   * sample:
  309.   * [email protected] [Inactive account]
  310.   */
  311. elseif (preg_match ("/(\S+@\S+\w).*inactive account/i",$body,$match)) {
  312. $result['rule_cat'] = 'inactive';
  313. $result['rule_no'] = '0181';
  314. $result['email'] = $match[1];
  315. }
  316.  
  317. /*
  318.   * rule: internal_error
  319.   * sample:
  320.   * Unable to switch to /var/vpopmail/domains/domain.com: input/output error. (#4.3.0)
  321.   */
  322. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*input\/output error/i",$body,$match)) {
  323. $result['rule_cat'] = 'internal_error';
  324. $result['rule_no'] = '0172';
  325. $result['bounce_type'] = 'hard';
  326. $result['remove'] = 1;
  327. $result['email'] = $match[1];
  328. }
  329.  
  330. /*
  331.   * rule: internal_error
  332.   * sample:
  333.   * can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350
  334.   */
  335. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*can not open new email file/i",$body,$match)) {
  336. $result['rule_cat'] = 'internal_error';
  337. $result['rule_no'] = '0173';
  338. $result['bounce_type'] = 'hard';
  339. $result['remove'] = 1;
  340. $result['email'] = $match[1];
  341. }
  342.  
  343. /*
  344.   * rule: defer
  345.   * sample:
  346.   * 111.111.111.111 failed after I sent the message.
  347.   * Remote host said: 451 mta283.mail.scd.yahoo.com Resources temporarily unavailable. Please try again later [#4.16.5].
  348.   */
  349. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*\n?.*Resources temporarily unavailable/i",$body,$match)) {
  350. $result['rule_cat'] = 'defer';
  351. $result['rule_no'] = '0163';
  352. $result['email'] = $match[1];
  353. }
  354.  
  355. /*
  356.   * rule: autoreply
  357.   * sample:
  358.   * AutoReply message from [email protected]
  359.   */
  360. elseif (preg_match ("/^AutoReply message from (\S+@\S+\w)/i",$body,$match)) {
  361. $result['rule_cat'] = 'autoreply';
  362. $result['rule_no'] = '0167';
  363. $result['email'] = $match[1];
  364. }
  365.  
  366. /*
  367.   * rule: western chars only
  368.   * sample:
  369.   * The user does not accept email in non-Western (non-Latin) character sets.
  370.   */
  371. elseif (preg_match ("/<(\S+@\S+\w)>.*\n?.*does not accept[^
  372. ]*non-Western/i",$body,$match)) {
  373. $result['rule_cat'] = 'latin_only';
  374. $result['rule_no'] = '0043';
  375. $result['email'] = $match[1];
  376. }
  377.  
  378. global $rule_categories, $bmh_newline;
  379. if ($result['rule_no'] == '0000') {
  380. if ($debug_mode) {
  381. echo 'Body:' . $bmh_newline . $body . $bmh_newline;
  382. echo $bmh_newline;
  383. }
  384. } else {
  385. if ($result['bounce_type'] === false) {
  386. $result['bounce_type'] = $rule_categories[$result['rule_cat']]['bounce_type'];
  387. $result['remove'] = $rule_categories[$result['rule_cat']]['remove'];
  388. }
  389. }
  390. return $result;
  391. }
  392.  
  393. /**
  394.  * Defined bounce parsing rules for standard DSN (Delivery Status Notification)
  395.  *
  396.  * @param string $dsn_msg human-readable explanation
  397.  * @param string $dsn_report delivery-status report
  398.  * @param boolean $debug_mode show debug info. or not
  399.  * @return array $result an array include the following fields: 'email', 'bounce_type','remove','rule_no','rule_cat'
  400.  * if we could NOT detect the type of bounce, return rule_no = '0000'
  401.  */
  402. function bmhDSNRules($dsn_msg,$dsn_report,$debug_mode=false) {
  403. // initialize the result array
  404. $result = array(
  405. 'email' => ''
  406. ,'bounce_type' => false
  407. ,'remove' => 0
  408. ,'rule_cat' => 'unrecognized'
  409. ,'rule_no' => '0000'
  410. );
  411. $action = false;
  412. $status_code = false;
  413. $diag_code = false;
  414.  
  415. // ======= parse $dsn_report ======
  416. // get the recipient email
  417. if (preg_match ("/Original-Recipient: rfc822;(.*)/i",$dsn_report,$match)) {
  418. $email_arr = imap_rfc822_parse_adrlist($match[1],'default.domain.name');
  419. if (isset($email_arr[0]->host) && $email_arr[0]->host != '.SYNTAX-ERROR.' && $email_arr[0]->host != 'default.domain.name' ) {
  420. $result['email'] = $email_arr[0]->mailbox.'@'.$email_arr[0]->host;
  421. }
  422. } else if (preg_match ("/Final-Recipient: rfc822;(.*)/i",$dsn_report,$match)) {
  423. $email_arr = imap_rfc822_parse_adrlist($match[1],'default.domain.name');
  424. if (isset($email_arr[0]->host) && $email_arr[0]->host != '.SYNTAX-ERROR.' && $email_arr[0]->host != 'default.domain.name' ) {
  425. $result['email'] = $email_arr[0]->mailbox.'@'.$email_arr[0]->host;
  426. }
  427. }
  428.  
  429. if (preg_match ("/Action: (.+)/i",$dsn_report,$match)) {
  430. $action = strtolower(trim($match[1]));
  431. }
  432.  
  433. if (preg_match ("/Status: ([0-9\.]+)/i",$dsn_report,$match)) {
  434. $status_code = $match[1];
  435. }
  436.  
  437. // Could be multi-line , if the new line is beginning with SPACE or HTAB
  438. if (preg_match ("/Diagnostic-Code:((?:[^\n]|\n[\t ])+)(?:\n[^\t ]|$)/is",$dsn_report,$match)) {
  439. $diag_code = $match[1];
  440. }
  441. // ======= rules ======
  442. if (empty($result['email'])) {
  443. /* email address is empty
  444.   * rule: full
  445.   * sample: DSN Message only
  446.   * User quota exceeded: SMTP <[email protected]>
  447.   */
  448. if (preg_match ("/quota exceed.*<(\S+@\S+\w)>/is",$dsn_msg,$match)) {
  449. $result['rule_cat'] = 'full';
  450. $result['rule_no'] = '0161';
  451. $result['email'] = $match[1];
  452. }
  453. } else {
  454. /* action could be one of them as RFC:1894
  455.   * "failed" / "delayed" / "delivered" / "relayed" / "expanded"
  456.   */
  457. switch ($action) {
  458. case 'failed':
  459. /* rule: full
  460.   * sample:
  461.   * Diagnostic-Code: X-Postfix; me.domain.com platform: said: 552 5.2.2 Over
  462.   * quota (in reply to RCPT TO command)
  463.   */
  464. if (preg_match ("/over.*quota/is",$diag_code)) {
  465. $result['rule_cat'] = 'full';
  466. $result['rule_no'] = '0105';
  467. }
  468. /* rule: full
  469.   * sample:
  470.   * Diagnostic-Code: SMTP; 552 Requested mailbox exceeds quota.
  471.   */
  472. elseif (preg_match ("/exceed.*quota/is",$diag_code)) {
  473. $result['rule_cat'] = 'full';
  474. $result['rule_no'] = '0129';
  475. }
  476. /* rule: full
  477.   * sample 1:
  478.   * Diagnostic-Code: smtp;552 5.2.2 This message is larger than the current system limit or the recipient's mailbox is full. Create a shorter message body or remove attachments and try sending it again.
  479.   * sample 2:
  480.   * Diagnostic-Code: X-Postfix; host mta5.us4.domain.com.int[111.111.111.111] said:
  481.   * 552 recipient storage full, try again later (in reply to RCPT TO command)
  482.   * sample 3:
  483.   * Diagnostic-Code: X-HERMES; host 127.0.0.1[127.0.0.1] said: 551 bounce as<the
  484.   * destination mailbox <[email protected]> is full> queue as
  485.   * [email protected] (in reply to end of
  486.   * DATA command)
  487.   */
  488. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*full/is",$diag_code)) {
  489. $result['rule_cat'] = 'full';
  490. $result['rule_no'] = '0145';
  491. }
  492. /* rule: full
  493.   * sample:
  494.   * Diagnostic-Code: SMTP; 452 Insufficient system storage
  495.   */
  496. elseif (preg_match ("/Insufficient system storage/is",$diag_code)) {
  497. $result['rule_cat'] = 'full';
  498. $result['rule_no'] = '0134';
  499. }
  500. /* rule: full
  501.   * sample 1:
  502.   * Diagnostic-Code: X-Postfix; cannot append message to destination file^M
  503.   * /var/mail/dale.me89g: error writing message: File too large^M
  504.   * sample 2:
  505.   * Diagnostic-Code: X-Postfix; cannot access mailbox /var/spool/mail/b8843022 for^M
  506.   * user xxxxx. error writing message: File too large
  507.   */
  508. elseif (preg_match ("/File too large/is",$diag_code)) {
  509. $result['rule_cat'] = 'full';
  510. $result['rule_no'] = '0192';
  511. }
  512. /* rule: oversize
  513.   * sample:
  514.   * Diagnostic-Code: smtp;552 5.2.2 This message is larger than the current system limit or the recipient's mailbox is full. Create a shorter message body or remove attachments and try sending it again.
  515.   */
  516. elseif (preg_match ("/larger than.*limit/is",$diag_code)) {
  517. $result['rule_cat'] = 'oversize';
  518. $result['rule_no'] = '0146';
  519. }
  520. /* rule: unknown
  521.   * sample:
  522.   * Diagnostic-Code: X-Notes; User xxxxx ([email protected]) not listed in public Name & Address Book
  523.   */
  524. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user)(.*)not(.*)list/is",$diag_code)) {
  525. $result['rule_cat'] = 'unknown';
  526. $result['rule_no'] = '0103';
  527. }
  528. /* rule: unknown
  529.   * sample:
  530.   * Diagnostic-Code: smtp; 450 user path no exist
  531.   */
  532. elseif (preg_match ("/user path no exist/is",$diag_code)) {
  533. $result['rule_cat'] = 'unknown';
  534. $result['rule_no'] = '0106';
  535. }
  536. /* rule: unknown
  537.   * sample 1:
  538.   * Diagnostic-Code: SMTP; 550 Relaying denied.
  539.   * sample 2:
  540.   * Diagnostic-Code: SMTP; 554 <[email protected]>: Relay access denied
  541.   * sample 3:
  542.   * Diagnostic-Code: SMTP; 550 relaying to <[email protected]> prohibited by administrator
  543.   */
  544. elseif (preg_match ("/Relay.*(?:denied|prohibited)/is",$diag_code)) {
  545. $result['rule_cat'] = 'unknown';
  546. $result['rule_no'] = '0108';
  547. }
  548. /* rule: unknown
  549.   * sample:
  550.   * Diagnostic-Code: SMTP; 554 qq Sorry, no valid recipients (#5.1.3)
  551.   */
  552. elseif (preg_match ("/no.*valid.*(?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  553. $result['rule_cat'] = 'unknown';
  554. $result['rule_no'] = '0185';
  555. }
  556. /* rule: unknown
  557.   * sample 1:
  558.   * Diagnostic-Code: SMTP; 550 «Dªk¦a§} - invalid address (#5.5.0)
  559.   * sample 2:
  560.   * Diagnostic-Code: SMTP; 550 Invalid recipient: <[email protected]>
  561.   * sample 3:
  562.   * Diagnostic-Code: SMTP; 550 <[email protected]>: Invalid User
  563.   */
  564. elseif (preg_match ("/Invalid.*(?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  565. $result['rule_cat'] = 'unknown';
  566. $result['rule_no'] = '0111';
  567. }
  568. /* rule: unknown
  569.   * sample:
  570.   * Diagnostic-Code: SMTP; 554 delivery error: dd Sorry your message to [email protected] cannot be delivered. This account has been disabled or discontinued [#102]. - mta173.mail.tpe.domain.com
  571.   */
  572. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*(?:disabled|discontinued)/is",$diag_code)) {
  573. $result['rule_cat'] = 'unknown';
  574. $result['rule_no'] = '0114';
  575. }
  576. /* rule: unknown
  577.   * sample:
  578.   * Diagnostic-Code: SMTP; 554 delivery error: dd This user doesn't have a domain.com account ([email protected]) [0] - mta134.mail.tpe.domain.com
  579.   */
  580. elseif (preg_match ("/user doesn't have.*account/is",$diag_code)) {
  581. $result['rule_cat'] = 'unknown';
  582. $result['rule_no'] = '0127';
  583. }
  584. /* rule: unknown
  585.   * sample:
  586.   * Diagnostic-Code: SMTP; 550 5.1.1 unknown or illegal alias: [email protected]
  587.   */
  588. elseif (preg_match ("/(?:unknown|illegal).*(?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  589. $result['rule_cat'] = 'unknown';
  590. $result['rule_no'] = '0128';
  591. }
  592. /* rule: unknown
  593.   * sample 1:
  594.   * Diagnostic-Code: SMTP; 450 mailbox unavailable.
  595.   * sample 2:
  596.   * Diagnostic-Code: SMTP; 550 5.7.1 Requested action not taken: mailbox not available
  597.   */
  598. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*(?:un|not\s+)available/is",$diag_code)) {
  599. $result['rule_cat'] = 'unknown';
  600. $result['rule_no'] = '0122';
  601. }
  602. /* rule: unknown
  603.   * sample:
  604.   * Diagnostic-Code: SMTP; 553 sorry, no mailbox here by that name (#5.7.1)
  605.   */
  606. elseif (preg_match ("/no (?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  607. $result['rule_cat'] = 'unknown';
  608. $result['rule_no'] = '0123';
  609. }
  610. /* rule: unknown
  611.   * sample 1:
  612.   * Diagnostic-Code: SMTP; 550 User ([email protected]) unknown.
  613.   * sample 2:
  614.   * Diagnostic-Code: SMTP; 553 5.3.0 <[email protected]>... Addressee unknown, relay=[111.111.111.000]
  615.   */
  616. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*unknown/is",$diag_code)) {
  617. $result['rule_cat'] = 'unknown';
  618. $result['rule_no'] = '0125';
  619. }
  620. /* rule: unknown
  621.   * sample 1:
  622.   * Diagnostic-Code: SMTP; 550 user disabled
  623.   * sample 2:
  624.   * Diagnostic-Code: SMTP; 452 4.2.1 mailbox temporarily disabled: [email protected]
  625.   */
  626. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*disabled/is",$diag_code)) {
  627. $result['rule_cat'] = 'unknown';
  628. $result['rule_no'] = '0133';
  629. }
  630. /* rule: unknown
  631.   * sample:
  632.   * Diagnostic-Code: SMTP; 550 <[email protected]>: Recipient address rejected: No such user ([email protected])
  633.   */
  634. elseif (preg_match ("/No such (?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  635. $result['rule_cat'] = 'unknown';
  636. $result['rule_no'] = '0143';
  637. }
  638. /* rule: unknown
  639.   * sample 1:
  640.   * Diagnostic-Code: SMTP; 550 MAILBOX NOT FOUND
  641.   * sample 2:
  642.   * Diagnostic-Code: SMTP; 550 Mailbox ( [email protected] ) not found or inactivated
  643.   */
  644. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*NOT FOUND/is",$diag_code)) {
  645. $result['rule_cat'] = 'unknown';
  646. $result['rule_no'] = '0136';
  647. }
  648. /* rule: unknown
  649.   * sample:
  650.   * Diagnostic-Code: X-Postfix; host m2w-in1.domain.com[111.111.111.000] said: 551
  651.   * <[email protected]> is a deactivated mailbox (in reply to RCPT TO
  652.   * command)
  653.   */
  654. elseif (preg_match ("/deactivated (?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  655. $result['rule_cat'] = 'unknown';
  656. $result['rule_no'] = '0138';
  657. }
  658. /* rule: unknown
  659.   * sample:
  660.   * Diagnostic-Code: SMTP; 550 <[email protected]> recipient rejected
  661.   * ...
  662.   * <<< 550 <[email protected]> recipient rejected
  663.   * 550 5.1.1 [email protected]... User unknown
  664.   */
  665. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*reject/is",$diag_code)) {
  666. $result['rule_cat'] = 'unknown';
  667. $result['rule_no'] = '0148';
  668. }
  669. /* rule: unknown
  670.   * sample:
  671.   * Diagnostic-Code: smtp; 5.x.0 - Message bounced by administrator (delivery attempts: 0)
  672.   */
  673. elseif (preg_match ("/bounce.*administrator/is",$diag_code)) {
  674. $result['rule_cat'] = 'unknown';
  675. $result['rule_no'] = '0151';
  676. }
  677. /* rule: unknown
  678.   * sample:
  679.   * Diagnostic-Code: SMTP; 550 <maxqin> is now disabled with MTA service.
  680.   */
  681. elseif (preg_match ("/<.*>.*disabled/is",$diag_code)) {
  682. $result['rule_cat'] = 'unknown';
  683. $result['rule_no'] = '0152';
  684. }
  685. /* rule: unknown
  686.   * sample:
  687.   * Diagnostic-Code: SMTP; 551 not our customer
  688.   */
  689. elseif (preg_match ("/not our customer/is",$diag_code)) {
  690. $result['rule_cat'] = 'unknown';
  691. $result['rule_no'] = '0154';
  692. }
  693. /* rule: unknown
  694.   * sample:
  695.   * Diagnostic-Code: smtp; 5.1.0 - Unknown address error 540-'Error: Wrong recipients' (delivery attempts: 0)
  696.   */
  697. elseif (preg_match ("/Wrong (?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  698. $result['rule_cat'] = 'unknown';
  699. $result['rule_no'] = '0159';
  700. }
  701. /* rule: unknown
  702.   * sample:
  703.   * Diagnostic-Code: smtp; 5.1.0 - Unknown address error 540-'Error: Wrong recipients' (delivery attempts: 0)
  704.   * sample 2:
  705.   * Diagnostic-Code: SMTP; 501 #5.1.1 bad address [email protected]
  706.   */
  707. elseif (preg_match ("/(?:unknown|bad).*(?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  708. $result['rule_cat'] = 'unknown';
  709. $result['rule_no'] = '0160';
  710. }
  711. /* rule: unknown
  712.   * sample:
  713.   * Diagnostic-Code: SMTP; 550 Command RCPT User <[email protected]> not OK
  714.   */
  715. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*not OK/is",$diag_code)) {
  716. $result['rule_cat'] = 'unknown';
  717. $result['rule_no'] = '0186';
  718. }
  719. /* rule: unknown
  720.   * sample:
  721.   * Diagnostic-Code: SMTP; 550 5.7.1 Access-Denied-XM.SSR-001
  722.   */
  723. elseif (preg_match ("/Access.*Denied/is",$diag_code)) {
  724. $result['rule_cat'] = 'unknown';
  725. $result['rule_no'] = '0189';
  726. }
  727. /* rule: unknown
  728.   * sample:
  729.   * Diagnostic-Code: SMTP; 550 5.1.1 <[email protected]>... email address lookup in domain map failed^M
  730.   */
  731. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*lookup.*fail/is",$diag_code)) {
  732. $result['rule_cat'] = 'unknown';
  733. $result['rule_no'] = '0195';
  734. }
  735. /* rule: unknown
  736.   * sample:
  737.   * Diagnostic-Code: SMTP; 550 User not a member of domain: <[email protected]>^M
  738.   */
  739. elseif (preg_match ("/(?:recipient|address|email|mailbox|user).*not.*member of domain/is",$diag_code)) {
  740. $result['rule_cat'] = 'unknown';
  741. $result['rule_no'] = '0198';
  742. }
  743. /* rule: unknown
  744.   * sample:
  745.   * Diagnostic-Code: SMTP; 550-"The recipient cannot be verified. Please check all recipients of this^M
  746.   */
  747. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*cannot be verified/is",$diag_code)) {
  748. $result['rule_cat'] = 'unknown';
  749. $result['rule_no'] = '0202';
  750. }
  751. /* rule: unknown
  752.   * sample:
  753.   * Diagnostic-Code: SMTP; 550 Unable to relay for [email protected]
  754.   */
  755. elseif (preg_match ("/Unable to relay/is",$diag_code)) {
  756. $result['rule_cat'] = 'unknown';
  757. $result['rule_no'] = '0203';
  758. }
  759. /* rule: unknown
  760.   * sample 1:
  761.   * Diagnostic-Code: SMTP; 550 [email protected]:user not exist
  762.   * sample 2:
  763.   * Diagnostic-Code: SMTP; 550 sorry, that recipient doesn't exist (#5.7.1)
  764.   */
  765. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*(?:n't|not) exist/is",$diag_code)) {
  766. $result['rule_cat'] = 'unknown';
  767. $result['rule_no'] = '0205';
  768. }
  769. /* rule: unknown
  770.   * sample:
  771.   * Diagnostic-Code: SMTP; 550-I'm sorry but [email protected] does not have an account here. I will not
  772.   */
  773. elseif (preg_match ("/not have an account/is",$diag_code)) {
  774. $result['rule_cat'] = 'unknown';
  775. $result['rule_no'] = '0207';
  776. }
  777. /* rule: unknown
  778.   * sample:
  779.   * Diagnostic-Code: SMTP; 550 This account is not [email protected]
  780.   */
  781. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*is not allowed/is",$diag_code)) {
  782. $result['rule_cat'] = 'unknown';
  783. $result['rule_no'] = '0220';
  784. }
  785. /* rule: inactive
  786.   * sample:
  787.   * Diagnostic-Code: SMTP; 550 <[email protected]>: inactive user
  788.   */
  789. elseif (preg_match ("/inactive.*(?:alias|account|recipient|address|email|mailbox|user)/is",$diag_code)) {
  790. $result['rule_cat'] = 'inactive';
  791. $result['rule_no'] = '0135';
  792. }
  793. /* rule: inactive
  794.   * sample:
  795.   * Diagnostic-Code: SMTP; 550 [email protected] Account Inactive
  796.   */
  797. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*Inactive/is",$diag_code)) {
  798. $result['rule_cat'] = 'inactive';
  799. $result['rule_no'] = '0155';
  800. }
  801. /* rule: inactive
  802.   * sample:
  803.   * Diagnostic-Code: SMTP; 550 <[email protected]>: Recipient address rejected: Account closed due to inactivity. No forwarding information is available.
  804.   */
  805. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user) closed due to inactivity/is",$diag_code)) {
  806. $result['rule_cat'] = 'inactive';
  807. $result['rule_no'] = '0170';
  808. }
  809. /* rule: inactive
  810.   * sample:
  811.   * Diagnostic-Code: SMTP; 550 <[email protected]>... User account not activated
  812.   */
  813. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user) not activated/is",$diag_code)) {
  814. $result['rule_cat'] = 'inactive';
  815. $result['rule_no'] = '0177';
  816. }
  817. /* rule: inactive
  818.   * sample 1:
  819.   * Diagnostic-Code: SMTP; 550 User suspended
  820.   * sample 2:
  821.   * Diagnostic-Code: SMTP; 550 account expired
  822.   */
  823. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*(?:suspend|expire)/is",$diag_code)) {
  824. $result['rule_cat'] = 'inactive';
  825. $result['rule_no'] = '0183';
  826. }
  827. /* rule: inactive
  828.   * sample:
  829.   * Diagnostic-Code: SMTP; 553 5.3.0 <[email protected]>... Recipient address no longer exists
  830.   */
  831. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*no longer exist/is",$diag_code)) {
  832. $result['rule_cat'] = 'inactive';
  833. $result['rule_no'] = '0184';
  834. }
  835. /* rule: inactive
  836.   * sample:
  837.   * Diagnostic-Code: SMTP; 553 VS10-RT Possible forgery or deactivated due to abuse (#5.1.1) 111.111.111.211^M
  838.   */
  839. elseif (preg_match ("/(?:forgery|abuse)/is",$diag_code)) {
  840. $result['rule_cat'] = 'inactive';
  841. $result['rule_no'] = '0196';
  842. }
  843. /* rule: inactive
  844.   * sample:
  845.   * Diagnostic-Code: SMTP; 553 mailbox [email protected] is restricted
  846.   */
  847. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*restrict/is",$diag_code)) {
  848. $result['rule_cat'] = 'inactive';
  849. $result['rule_no'] = '0209';
  850. }
  851. /* rule: inactive
  852.   * sample:
  853.   * Diagnostic-Code: SMTP; 550 <[email protected]>: User status is locked.
  854.   */
  855. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*locked/is",$diag_code)) {
  856. $result['rule_cat'] = 'inactive';
  857. $result['rule_no'] = '0228';
  858. }
  859. /* rule: user_reject
  860.   * sample:
  861.   * Diagnostic-Code: SMTP; 553 User refused to receive this mail.
  862.   */
  863. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user) refused/is",$diag_code)) {
  864. $result['rule_cat'] = 'user_reject';
  865. $result['rule_no'] = '0156';
  866. }
  867. /* rule: user_reject
  868.   * sample:
  869.   * Diagnostic-Code: SMTP; 501 [email protected] Sender email is not in my domain
  870.   */
  871. elseif (preg_match ("/sender.*not/is",$diag_code)) {
  872. $result['rule_cat'] = 'user_reject';
  873. $result['rule_no'] = '0206';
  874. }
  875. /* rule: command_reject
  876.   * sample:
  877.   * Diagnostic-Code: SMTP; 554 Message refused
  878.   */
  879. elseif (preg_match ("/Message refused/is",$diag_code)) {
  880. $result['rule_cat'] = 'command_reject';
  881. $result['rule_no'] = '0175';
  882. }
  883. /* rule: command_reject
  884.   * sample:
  885.   * Diagnostic-Code: SMTP; 550 5.0.0 <[email protected]>... No permit
  886.   */
  887. elseif (preg_match ("/No permit/is",$diag_code)) {
  888. $result['rule_cat'] = 'command_reject';
  889. $result['rule_no'] = '0190';
  890. }
  891. /* rule: command_reject
  892.   * sample:
  893.   * Diagnostic-Code: SMTP; 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.5.3 - chkuser)
  894.   */
  895. elseif (preg_match ("/domain isn't in.*allowed rcpthost/is",$diag_code)) {
  896. $result['rule_cat'] = 'command_reject';
  897. $result['rule_no'] = '0191';
  898. }
  899. /* rule: command_reject
  900.   * sample:
  901.   * Diagnostic-Code: SMTP; 553 AUTH FAILED - [email protected]^M
  902.   */
  903. elseif (preg_match ("/AUTH FAILED/is",$diag_code)) {
  904. $result['rule_cat'] = 'command_reject';
  905. $result['rule_no'] = '0197';
  906. }
  907. /* rule: command_reject
  908.   * sample 1:
  909.   * Diagnostic-Code: SMTP; 550 relay not permitted^M
  910.   * sample 2:
  911.   * Diagnostic-Code: SMTP; 530 5.7.1 Relaying not allowed: [email protected]
  912.   */
  913. elseif (preg_match ("/relay.*not.*(?:permit|allow)/is",$diag_code)) {
  914. $result['rule_cat'] = 'command_reject';
  915. $result['rule_no'] = '0201';
  916. }
  917. /* rule: command_reject
  918.   * sample:
  919.   *
  920.   * Diagnostic-Code: SMTP; 550 not local host domain.com, not a gateway
  921.   */
  922. elseif (preg_match ("/not local host/is",$diag_code)) {
  923. $result['rule_cat'] = 'command_reject';
  924. $result['rule_no'] = '0204';
  925. }
  926. /* rule: command_reject
  927.   * sample:
  928.   * Diagnostic-Code: SMTP; 500 Unauthorized relay msg rejected
  929.   */
  930. elseif (preg_match ("/Unauthorized relay/is",$diag_code)) {
  931. $result['rule_cat'] = 'command_reject';
  932. $result['rule_no'] = '0215';
  933. }
  934. /* rule: command_reject
  935.   * sample:
  936.   * Diagnostic-Code: SMTP; 554 Transaction failed
  937.   */
  938. elseif (preg_match ("/Transaction.*fail/is",$diag_code)) {
  939. $result['rule_cat'] = 'command_reject';
  940. $result['rule_no'] = '0221';
  941. }
  942. /* rule: command_reject
  943.   * sample:
  944.   * Diagnostic-Code: smtp;554 5.5.2 Invalid data in message
  945.   */
  946. elseif (preg_match ("/Invalid data/is",$diag_code)) {
  947. $result['rule_cat'] = 'command_reject';
  948. $result['rule_no'] = '0223';
  949. }
  950. /* rule: command_reject
  951.   * sample:
  952.   * Diagnostic-Code: SMTP; 550 Local user only or Authentication mechanism
  953.   */
  954. elseif (preg_match ("/Local user only/is",$diag_code)) {
  955. $result['rule_cat'] = 'command_reject';
  956. $result['rule_no'] = '0224';
  957. }
  958. /* rule: command_reject
  959.   * sample:
  960.   * Diagnostic-Code: SMTP; 550-ds176.domain.com [111.111.111.211] is currently not permitted to
  961.   * relay through this server. Perhaps you have not logged into the pop/imap
  962.   * server in the last 30 minutes or do not have SMTP Authentication turned on
  963.   * in your email client.
  964.   */
  965. elseif (preg_match ("/not.*permit.*to/is",$diag_code)) {
  966. $result['rule_cat'] = 'command_reject';
  967. $result['rule_no'] = '0225';
  968. }
  969. /* rule: content_reject
  970.   * sample:
  971.   * Diagnostic-Code: SMTP; 550 Content reject. FAAAANsG60M9BmDT.1
  972.   */
  973. elseif (preg_match ("/Content reject/is",$diag_code)) {
  974. $result['rule_cat'] = 'content_reject';
  975. $result['rule_no'] = '0165';
  976. }
  977. /* rule: content_reject
  978.   * sample:
  979.   * Diagnostic-Code: SMTP; 552 MessageWall: MIME/REJECT: Invalid structure
  980.   */
  981. elseif (preg_match ("/MIME\/REJECT/is",$diag_code)) {
  982. $result['rule_cat'] = 'content_reject';
  983. $result['rule_no'] = '0212';
  984. }
  985. /* rule: content_reject
  986.   * sample:
  987.   * Diagnostic-Code: smtp; 554 5.6.0 Message with invalid header rejected, id=13462-01 - MIME error: error: UnexpectedBound: part didn't end with expected boundary [in multipart message]; EOSToken: EOF; EOSType: EOF
  988.   */
  989. elseif (preg_match ("/MIME error/is",$diag_code)) {
  990. $result['rule_cat'] = 'content_reject';
  991. $result['rule_no'] = '0217';
  992. }
  993. /* rule: content_reject
  994.   * sample:
  995.   * Diagnostic-Code: SMTP; 553 Mail data refused by AISP, rule [169648].
  996.   */
  997. elseif (preg_match ("/Mail data refused.*AISP/is",$diag_code)) {
  998. $result['rule_cat'] = 'content_reject';
  999. $result['rule_no'] = '0218';
  1000. }
  1001. /* rule: dns_unknown
  1002.   * sample:
  1003.   * Diagnostic-Code: SMTP; 550 Host unknown
  1004.   */
  1005. elseif (preg_match ("/Host unknown/is",$diag_code)) {
  1006. $result['rule_cat'] = 'dns_unknown';
  1007. $result['rule_no'] = '0130';
  1008. }
  1009. /* rule: dns_unknown
  1010.   * sample:
  1011.   * Diagnostic-Code: SMTP; 553 Specified domain is not allowed.
  1012.   */
  1013. elseif (preg_match ("/Specified domain.*not.*allow/is",$diag_code)) {
  1014. $result['rule_cat'] = 'dns_unknown';
  1015. $result['rule_no'] = '0180';
  1016. }
  1017. /* rule: dns_unknown
  1018.   * sample:
  1019.   * Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to
  1020.   * 111.111.11.112[111.111.11.112]: No route to host
  1021.   */
  1022. elseif (preg_match ("/No route to host/is",$diag_code)) {
  1023. $result['rule_cat'] = 'dns_unknown';
  1024. $result['rule_no'] = '0188';
  1025. }
  1026. /* rule: dns_unknown
  1027.   * sample:
  1028.   * Diagnostic-Code: SMTP; 550 unrouteable address
  1029.   */
  1030. elseif (preg_match ("/unrouteable address/is",$diag_code)) {
  1031. $result['rule_cat'] = 'dns_unknown';
  1032. $result['rule_no'] = '0208';
  1033. }
  1034. /* rule: defer
  1035.   * sample:
  1036.   * Diagnostic-Code: SMTP; 451 System(u) busy, try again later.
  1037.   */
  1038. elseif (preg_match ("/System.*busy/is",$diag_code)) {
  1039. $result['rule_cat'] = 'defer';
  1040. $result['rule_no'] = '0112';
  1041. }
  1042. /* rule: defer
  1043.   * sample:
  1044.   * Diagnostic-Code: SMTP; 451 mta172.mail.tpe.domain.com Resources temporarily unavailable. Please try again later. [#4.16.4:70].
  1045.   */
  1046. elseif (preg_match ("/Resources temporarily unavailable/is",$diag_code)) {
  1047. $result['rule_cat'] = 'defer';
  1048. $result['rule_no'] = '0116';
  1049. }
  1050. /* rule: antispam, deny ip
  1051.   * sample:
  1052.   * Diagnostic-Code: SMTP; 554 sender is rejected: 0,mx20,wKjR5bDrnoM2yNtEZVAkBg==.32467S2
  1053.   */
  1054. elseif (preg_match ("/sender is rejected/is",$diag_code)) {
  1055. $result['rule_cat'] = 'antispam';
  1056. $result['rule_no'] = '0101';
  1057. }
  1058. /* rule: antispam, deny ip
  1059.   * sample:
  1060.   * Diagnostic-Code: SMTP; 554 <unknown[111.111.111.000]>: Client host rejected: Access denied
  1061.   */
  1062. elseif (preg_match ("/Client host rejected/is",$diag_code)) {
  1063. $result['rule_cat'] = 'antispam';
  1064. $result['rule_no'] = '0102';
  1065. }
  1066. /* rule: antispam, mismatch ip
  1067.   * sample:
  1068.   * Diagnostic-Code: SMTP; 554 Connection refused(mx). MAIL FROM [[email protected]] mismatches client IP [111.111.111.000].
  1069.   */
  1070. elseif (preg_match ("/MAIL FROM(.*)mismatches client IP/is",$diag_code)) {
  1071. $result['rule_cat'] = 'antispam';
  1072. $result['rule_no'] = '0104';
  1073. }
  1074. /* rule: antispam, deny ip
  1075.   * sample:
  1076.   * Diagnostic-Code: SMTP; 554 Please visit http:// antispam.domain.com/denyip.php?IP=111.111.111.000 (#5.7.1)
  1077.   */
  1078. elseif (preg_match ("/denyip/is",$diag_code)) {
  1079. $result['rule_cat'] = 'antispam';
  1080. $result['rule_no'] = '0144';
  1081. }
  1082. /* rule: antispam, deny ip
  1083.   * sample:
  1084.   * Diagnostic-Code: SMTP; 554 Service unavailable; Client host [111.111.111.211] blocked using dynablock.domain.com; Your message could not be delivered due to complaints we received regarding the IP address you're using or your ISP. See http:// blackholes.domain.com/ Error: WS-02^M
  1085.   */
  1086. elseif (preg_match ("/client host.*blocked/is",$diag_code)) {
  1087. $result['rule_cat'] = 'antispam';
  1088. $result['rule_no'] = '0201';
  1089. }
  1090. /* rule: antispam, reject
  1091.   * sample:
  1092.   * Diagnostic-Code: SMTP; 550 Requested action not taken: mail IsCNAPF76kMDARUY.56621S2 is rejected,mx3,BM
  1093.   */
  1094. elseif (preg_match ("/mail.*reject/is",$diag_code)) {
  1095. $result['rule_cat'] = 'antispam';
  1096. $result['rule_no'] = '0147';
  1097. }
  1098. /* rule: antispam
  1099.   * sample:
  1100.   * Diagnostic-Code: SMTP; 552 sorry, the spam message is detected (#5.6.0)
  1101.   */
  1102. elseif (preg_match ("/spam.*detect/is",$diag_code)) {
  1103. $result['rule_cat'] = 'antispam';
  1104. $result['rule_no'] = '0162';
  1105. }
  1106. /* rule: antispam
  1107.   * sample:
  1108.   * Diagnostic-Code: SMTP; 554 5.7.1 Rejected as Spam see: http:// rejected.domain.com/help/spam/rejected.html
  1109.   */
  1110. elseif (preg_match ("/reject.*spam/is",$diag_code)) {
  1111. $result['rule_cat'] = 'antispam';
  1112. $result['rule_no'] = '0216';
  1113. }
  1114. /* rule: antispam
  1115.   * sample:
  1116.   * Diagnostic-Code: SMTP; 553 5.7.1 <[email protected]>... SpamTrap=reject mode, dsn=5.7.1, Message blocked by BOX Solutions (www.domain.com) SpamTrap Technology, please contact the domain.com site manager for help: (ctlusr8012).^M
  1117.   */
  1118. elseif (preg_match ("/SpamTrap/is",$diag_code)) {
  1119. $result['rule_cat'] = 'antispam';
  1120. $result['rule_no'] = '0200';
  1121. }
  1122. /* rule: antispam, mailfrom mismatch
  1123.   * sample:
  1124.   * Diagnostic-Code: SMTP; 550 Verify mailfrom failed,blocked
  1125.   */
  1126. elseif (preg_match ("/Verify mailfrom failed/is",$diag_code)) {
  1127. $result['rule_cat'] = 'antispam';
  1128. $result['rule_no'] = '0210';
  1129. }
  1130. /* rule: antispam, mailfrom mismatch
  1131.   * sample:
  1132.   * Diagnostic-Code: SMTP; 550 Error: MAIL FROM is mismatched with message header from address!
  1133.   */
  1134. elseif (preg_match ("/MAIL.*FROM.*mismatch/is",$diag_code)) {
  1135. $result['rule_cat'] = 'antispam';
  1136. $result['rule_no'] = '0226';
  1137. }
  1138. /* rule: antispam
  1139.   * sample:
  1140.   * Diagnostic-Code: SMTP; 554 5.7.1 Message scored too high on spam scale. For help, please quote incident ID 22492290.
  1141.   */
  1142. elseif (preg_match ("/spam scale/is",$diag_code)) {
  1143. $result['rule_cat'] = 'antispam';
  1144. $result['rule_no'] = '0211';
  1145. }
  1146. /* rule: antispam
  1147.   * sample:
  1148.   * Diagnostic-Code: SMTP; 554 5.7.1 reject: Client host bypassing service provider's mail relay: ds176.domain.com
  1149.   8?
  1150.   elseif (preg_match ("/Client host bypass/is",$diag_code)) {
  1151.   $result['rule_cat'] = 'antispam';
  1152.   $result['rule_no'] = '0229';
  1153.   }
  1154.   /* rule: antispam
  1155.   * sample:
  1156.   * Diagnostic-Code: SMTP; 550 sorry, it seems as a junk mail
  1157.   */
  1158. elseif (preg_match ("/junk mail/is",$diag_code)) {
  1159. $result['rule_cat'] = 'antispam';
  1160. $result['rule_no'] = '0230';
  1161. }
  1162. /* rule: antispam
  1163.   * sample:
  1164.   * Diagnostic-Code: SMTP; 553-Message filtered. Please see the FAQs section on spam
  1165.   */
  1166. elseif (preg_match ("/message filtered/is",$diag_code)) {
  1167. $result['rule_cat'] = 'antispam';
  1168. $result['rule_no'] = '0227';
  1169. }
  1170. /* rule: antispam, subject filter
  1171.   * sample:
  1172.   * Diagnostic-Code: SMTP; 554 5.7.1 The message from (<[email protected]>) with the subject of ( *(ca2639) 7|-{%2E* : {2"(%EJ;y} (SBI$#$@<K*:7s1!=l~) matches a profile the Internet community may consider spam. Please revise your message before resending.
  1173.   */
  1174. elseif (preg_match ("/subject.*consider.*spam/is",$diag_code)) {
  1175. $result['rule_cat'] = 'antispam';
  1176. $result['rule_no'] = '0222';
  1177. }
  1178. /* rule: internal_error
  1179.   * sample:
  1180.   * Diagnostic-Code: SMTP; 451 Temporary local problem - please try later
  1181.   */
  1182. elseif (preg_match ("/Temporary local problem/is",$diag_code)) {
  1183. $result['rule_cat'] = 'internal_error';
  1184. $result['rule_no'] = '0142';
  1185. }
  1186. /* rule: internal_error
  1187.   * sample:
  1188.   * Diagnostic-Code: SMTP; 553 5.3.5 system config error
  1189.   */
  1190. elseif (preg_match ("/system config error/is",$diag_code)) {
  1191. $result['rule_cat'] = 'internal_error';
  1192. $result['rule_no'] = '0153';
  1193. }
  1194. /* rule: delayed
  1195.   * sample:
  1196.   * Diagnostic-Code: X-Postfix; delivery temporarily suspended: conversation with^M
  1197.   * 111.111.111.11[111.111.111.11] timed out while sending end of data -- message may be^M
  1198.   * sent more than once
  1199.   */
  1200. elseif (preg_match ("/delivery.*suspend/is",$diag_code)) {
  1201. $result['rule_cat'] = 'delayed';
  1202. $result['rule_no'] = '0213';
  1203. }
  1204.  
  1205. // =========== rules based on the dsn_msg ===============
  1206. /* rule: unknown
  1207.   * sample:
  1208.   * ----- The following addresses had permanent fatal errors -----
  1209.   * ----- Transcript of session follows -----
  1210.   * ... while talking to mta1.domain.com.:
  1211.   * >>> DATA
  1212.   * <<< 503 All recipients are invalid
  1213.   * 554 5.0.0 Service unavailable
  1214.   */
  1215. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user)(.*)invalid/i",$dsn_msg)) {
  1216. $result['rule_cat'] = 'unknown';
  1217. $result['rule_no'] = '0107';
  1218. }
  1219. /* rule: unknown
  1220.   * sample:
  1221.   * ----- Transcript of session follows -----
  1222.   * [email protected]... Deferred: No such file or directory
  1223.   */
  1224. elseif (preg_match ("/Deferred.*No such.*(?:file|directory)/i",$dsn_msg)) {
  1225. $result['rule_cat'] = 'unknown';
  1226. $result['rule_no'] = '0141';
  1227. }
  1228. /* rule: unknown
  1229.   * sample:
  1230.   * Failed to deliver to '<[email protected]>'^M
  1231.   * LOCAL module(account xxxx) reports:^M
  1232.   * mail receiving disabled^M
  1233.   */
  1234. elseif (preg_match ("/mail receiving disabled/i",$dsn_msg)) {
  1235. $result['rule_cat'] = 'unknown';
  1236. $result['rule_no'] = '0194';
  1237. }
  1238. /* rule: unknown
  1239.   * sample:
  1240.   * - These recipients of your message have been processed by the mail server:^M
  1241.   * [email protected]; Failed; 5.1.1 (bad destination mailbox address)
  1242.   */
  1243. elseif (preg_match ("/bad.*(?:alias|account|recipient|address|email|mailbox|user)/i",$dsn_msg)) {
  1244. $result['rule_cat'] = 'unknown';
  1245. $result['rule_no'] = '227';
  1246. }
  1247. /* rule: full
  1248.   * sample 1:
  1249.   * This Message was undeliverable due to the following reason:
  1250.   * The user(s) account is temporarily over quota.
  1251.   * sample 2:
  1252.   * Recipient address: [email protected]
  1253.   * Reason: Over quota
  1254.   */
  1255. elseif (preg_match ("/over.*quota/i",$dsn_msg)) {
  1256. $result['rule_cat'] = 'full';
  1257. $result['rule_no'] = '0131';
  1258. }
  1259. /* rule: full
  1260.   * sample:
  1261.   * Sorry the recipient quota limit is exceeded.
  1262.   * This message is returned as an error.
  1263.   */
  1264. elseif (preg_match ("/quota.*exceeded/i",$dsn_msg)) {
  1265. $result['rule_cat'] = 'full';
  1266. $result['rule_no'] = '0150';
  1267. }
  1268. /* rule: full
  1269.   * sample:
  1270.   * The user to whom this message was addressed has exceeded the allowed mailbox
  1271.   * quota. Please resend the message at a later time.
  1272.   */
  1273. elseif (preg_match ("/exceed.*\n?.*quota/i",$dsn_msg)) {
  1274. $result['rule_cat'] = 'full';
  1275. $result['rule_no'] = '0187';
  1276. }
  1277. /* rule: full
  1278.   * sample 1:
  1279.   * Failed to deliver to '<[email protected]>'
  1280.   * LOCAL module(account xxxxxx) reports:
  1281.   * account is full (quota exceeded)
  1282.   * sample 2:
  1283.   * Error in fabiomod_sql_glob_init: no data source specified - database access disabled
  1284.   * [Fri Feb 17 23:29:38 PST 2006] full error for caltsmy:
  1285.   * that member's mailbox is full
  1286.   * 550 5.0.0 <[email protected]>... Can't create output
  1287.   */
  1288. elseif (preg_match ("/(?:alias|account|recipient|address|email|mailbox|user).*full/i",$dsn_msg)) {
  1289. $result['rule_cat'] = 'full';
  1290. $result['rule_no'] = '0132';
  1291. }
  1292. /* rule: full
  1293.   * sample:
  1294.   * gaosong "(0), ErrMsg=Mailbox space not enough (space limit is 10240KB)
  1295.   */
  1296. elseif (preg_match ("/space.*not.*enough/i",$dsn_msg)) {
  1297. $result['rule_cat'] = 'full';
  1298. $result['rule_no'] = '0219';
  1299. }
  1300. /* rule: defer
  1301.   * sample 1:
  1302.   * ----- Transcript of session follows -----
  1303.   * [email protected]... Deferred: Connection refused by nomail.tpe.domain.com.
  1304.   * Message could not be delivered for 5 days
  1305.   * Message will be deleted from queue
  1306.   * sample 2:
  1307.   * 451 4.4.1 reply: read error from www.domain.com.
  1308.   * [email protected]... Deferred: Connection reset by www.domain.com.
  1309.   */
  1310. elseif (preg_match ("/Deferred.*Connection (?:refused|reset)/i",$dsn_msg)) {
  1311. $result['rule_cat'] = 'defer';
  1312. $result['rule_no'] = '0115';
  1313. }
  1314. /* rule: dns_unknown
  1315.   * sample:
  1316.   * ----- The following addresses had permanent fatal errors -----
  1317.   * Tan XXXX SSSS <[email protected]>
  1318.   * ----- Transcript of session follows -----
  1319.   * 553 5.1.2 XXXX SSSS <[email protected]>... Invalid host name
  1320.   */
  1321. elseif (preg_match ("/Invalid host name/i",$dsn_msg)) {
  1322. $result['rule_cat'] = 'dns_unknown';
  1323. $result['rule_no'] = '0109';
  1324. }
  1325. /* rule: dns_unknown
  1326.   * sample:
  1327.   * ----- Transcript of session follows -----
  1328.   * [email protected]... Deferred: mail.domain.com.: No route to host
  1329.   */
  1330. elseif (preg_match ("/Deferred.*No route to host/i",$dsn_msg)) {
  1331. $result['rule_cat'] = 'dns_unknown';
  1332. $result['rule_no'] = '0109';
  1333. }
  1334. /* rule: dns_unknown
  1335.   * sample:
  1336.   * ----- Transcript of session follows -----
  1337.   * 550 5.1.2 [email protected]... Host unknown (Name server: .: no data known)
  1338.   */
  1339. elseif (preg_match ("/Host unknown/i",$dsn_msg)) {
  1340. $result['rule_cat'] = 'dns_unknown';
  1341. $result['rule_no'] = '0140';
  1342. }
  1343. /* rule: dns_unknown
  1344.   * sample:
  1345.   * ----- Transcript of session follows -----
  1346.   * 451 HOTMAIL.com.tw: Name server timeout
  1347.   * Message could not be delivered for 5 days
  1348.   * Message will be deleted from queue
  1349.   */
  1350. elseif (preg_match ("/Name server timeout/i",$dsn_msg)) {
  1351. $result['rule_cat'] = 'dns_unknown';
  1352. $result['rule_no'] = '0118';
  1353. }
  1354. /* rule: dns_unknown
  1355.   * sample:
  1356.   * ----- Transcript of session follows -----
  1357.   * [email protected]... Deferred: Connection timed out with hkfight.com.
  1358.   * Message could not be delivered for 5 days
  1359.   * Message will be deleted from queue
  1360.   */
  1361. elseif (preg_match ("/Deferred.*Connection.*tim(?:e|ed).*out/i",$dsn_msg)) {
  1362. $result['rule_cat'] = 'dns_unknown';
  1363. $result['rule_no'] = '0119';
  1364. }
  1365. /* rule: dns_unknown
  1366.   * sample:
  1367.   * ----- Transcript of session follows -----
  1368.   * [email protected]... Deferred: Name server: domain.com.: host name lookup failure
  1369.   */
  1370. elseif (preg_match ("/Deferred.*host name lookup failure/i",$dsn_msg)) {
  1371. $result['rule_cat'] = 'dns_unknown';
  1372. $result['rule_no'] = '0121';
  1373. }
  1374. /* rule: dns_loop
  1375.   * sample:
  1376.   * ----- Transcript of session follows -----^M
  1377.   * 554 5.0.0 MX list for znet.ws. points back to mail01.domain.com^M
  1378.   * 554 5.3.5 Local configuration error^M
  1379.   */
  1380. elseif (preg_match ("/MX list.*point.*back/i",$dsn_msg)) {
  1381. $result['rule_cat'] = 'dns_loop';
  1382. $result['rule_no'] = '0199';
  1383. }
  1384. /* rule: internal_error
  1385.   * sample:
  1386.   * ----- Transcript of session follows -----
  1387.   * 451 4.0.0 I/O error
  1388.   */
  1389. elseif (preg_match ("/I\/O error/i",$dsn_msg)) {
  1390. $result['rule_cat'] = 'internal_error';
  1391. $result['rule_no'] = '0120';
  1392. }
  1393. /* rule: internal_error
  1394.   * sample:
  1395.   * Failed to deliver to '[email protected]'^M
  1396.   * SMTP module(domain domain.com) reports:^M
  1397.   * connection with mx1.mail.domain.com is broken^M
  1398.   */
  1399. elseif (preg_match ("/connection.*broken/i",$dsn_msg)) {
  1400. $result['rule_cat'] = 'internal_error';
  1401. $result['rule_no'] = '0231';
  1402. }
  1403. /* rule: other
  1404.   * sample:
  1405.   * Delivery to the following recipients failed.
  1406.   */
  1407. elseif (preg_match ("/Delivery to the following recipients failed.*\n.*\n.*".$result['email']."/i",$dsn_msg)) {
  1408. $result['rule_cat'] = 'other';
  1409. $result['rule_no'] = '0176';
  1410. }
  1411.  
  1412. // Followings are wind-up rule: must be the last one
  1413. // many other rules msg end up with "550 5.1.1 ... User unknown"
  1414. // many other rules msg end up with "554 5.0.0 Service unavailable"
  1415.  
  1416. /* rule: unknown
  1417.   * sample 1:
  1418.   * ----- The following addresses had permanent fatal errors -----^M
  1419.   * (reason: User unknown)^M
  1420.   * sample 2:
  1421.   * 550 5.1.1 [email protected]... User unknown^M
  1422.   */
  1423. elseif (preg_match ("/User unknown/i",$dsn_msg)) {
  1424. $result['rule_cat'] = 'unknown';
  1425. $result['rule_no'] = '0193';
  1426. }
  1427. /* rule: unknown
  1428.   * sample:
  1429.   * 554 5.0.0 Service unavailable
  1430.   */
  1431. elseif (preg_match ("/Service unavailable/i",$dsn_msg)) {
  1432. $result['rule_cat'] = 'unknown';
  1433. $result['rule_no'] = '0214';
  1434. }
  1435. break;
  1436. case 'delayed':
  1437. $result['rule_cat'] = 'delayed';
  1438. $result['rule_no'] = '0110';
  1439. break;
  1440. case 'delivered':
  1441. case 'relayed':
  1442. case 'expanded': // unhandled cases
  1443. break;
  1444. default :
  1445. break;
  1446. }
  1447. }
  1448.  
  1449. global $rule_categories, $bmh_newline;
  1450. if ($result['rule_no'] == '0000') {
  1451. if ($debug_mode) {
  1452. echo 'email: ' . $result['email'] . $bmh_newline;
  1453. echo 'Action: ' . $action . $bmh_newline;
  1454. echo 'Status: ' . $status_code . $bmh_newline;
  1455. echo 'Diagnostic-Code: ' . $diag_code . $bmh_newline;
  1456. echo "DSN Message:<br />\n" . $dsn_msg . $bmh_newline;
  1457. echo $bmh_newline;
  1458. }
  1459. } else {
  1460. if ($result['bounce_type'] === false) {
  1461. $result['bounce_type'] = $rule_categories[$result['rule_cat']]['bounce_type'];
  1462. $result['remove'] = $rule_categories[$result['rule_cat']]['remove'];
  1463. }
  1464. }
  1465. return $result;
  1466. }
  1467. ?>

URL: http://sourceforge.net/projects/bmh

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.