Code Duplication    Length = 5-6 lines in 13 locations

src/BounceMailHandler/phpmailer-bmh_rules.php 13 locations

@@ 172-176 (lines=5) @@
169
   *   #        (expanded from: <[email protected]>)         #
170
   *   #                                                        #
171
   */
172
  elseif (preg_match("/Can't\s+create\s+output.*<(\S+@\S+\w)>/is", $body, $match)) {
173
    $result['rule_cat'] = 'unknown';
174
    $result['rule_no'] = '0169';
175
    $result['email'] = $match[1];
176
  } /* rule: unknown
177
   * sample:
178
   *   ????????????????:
179
   *   [email protected] : ????, ?????.
@@ 197-201 (lines=5) @@
194
   *   Delivery to the following recipients failed.
195
   *   [email protected]
196
   */
197
  elseif (preg_match("/delivery[^\n\r]+failed\S*\s+(\S+@\S+\w)\s/i", $body, $match)) {
198
    $result['rule_cat'] = 'unknown';
199
    $result['rule_no'] = '0013';
200
    $result['email'] = $match[1];
201
  } /* rule: unknown
202
   * sample:
203
   *   A message that you sent could not be delivered to one or more of its
204
   *   recipients. This is a permanent error. The following address(es) failed:
@@ 218-222 (lines=5) @@
215
   *   111.111.111.11 does not like recipient.
216
   *   Remote host said: 550 Invalid recipient: <[email protected]>
217
   */
218
  elseif (preg_match("/Invalid.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/is", $body, $match)) {
219
    $result['rule_cat'] = 'unknown';
220
    $result['rule_no'] = '0233';
221
    $result['email'] = $match[1];
222
  } /* rule: unknown
223
   * sample:
224
   *   Sent >>> RCPT TO: <[email protected]>
225
   *   Received <<< 550 [email protected]... No such user
@@ 231-235 (lines=5) @@
228
   *   [email protected]
229
   *   *****************     End of message     ***************
230
   */
231
  elseif (preg_match("/No\s+such.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/is", $body, $match)) {
232
    $result['rule_cat'] = 'unknown';
233
    $result['rule_no'] = '0234';
234
    $result['email'] = $match[1];
235
  } /* rule: unknown
236
   * sample:
237
   *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
238
   */
@@ 260-264 (lines=5) @@
257
   *   mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
258
   *   554 <[email protected]>... Service unavailable
259
   */
260
  elseif (preg_match("/quota\s+exceeded.*<(\S+@\S+\w)>/is", $body, $match)) {
261
    $result['rule_cat'] = 'full';
262
    $result['rule_no'] = '0126';
263
    $result['email'] = $match[1];
264
  } /* rule: full
265
   * sample:
266
   *   Hi. This is the qmail-send program at 263.domain.com.
267
   *   <[email protected]>:
@@ 285-289 (lines=5) @@
282
   * sample:
283
   *   The message to [email protected] is bounced because : Quota exceed the hard limit
284
   */
285
  elseif (preg_match("/The message to (\S+@\S+\w)\s.*bounce.*Quota exceed/i", $body, $match)) {
286
    $result['rule_cat'] = 'full';
287
    $result['rule_no'] = '0168';
288
    $result['email'] = $match[1];
289
  } /* rule: full
290
   * sample:
291
   *   Message rejected. Not enough storage space in user's mailbox to accept message.
292
   */
@@ 307-311 (lines=5) @@
304
  } /*
305
   * <[email protected]> is restricted
306
   */
307
  elseif (preg_match("/(\S+@\S+\w).*n? is restricted/i", $body, $match)) {
308
    $result['rule_cat'] = 'inactive';
309
    $result['rule_no'] = '0201';
310
    $result['email'] = $match[1];
311
  } /* rule: inactive
312
   * sample:
313
   *   [email protected] [Inactive account]
314
   */
@@ 322-326 (lines=5) @@
319
   *<[email protected]>: host mx3.HOTMAIL.COM said: 550
320
   * Requested action not taken: mailbox unavailable (in reply to RCPT TO command)
321
   */
322
  elseif (preg_match("/<(\S+@\S+\w)>.*\n.*mailbox unavailable/i", $body, $match)) {
323
    $result['rule_cat'] = 'unknown';
324
    $result['rule_no'] = '124';
325
    $result['email'] = $match[1];
326
  } /*
327
   * rule: mailbox unknown;
328
   * sample:
329
   * [email protected]
@@ 337-341 (lines=5) @@
334
   * http://support.google.com/mail/bin/answer.py?answer=6596 n7si4762785wiy.46
335
   * (in reply to RCPT TO command)
336
   */
337
  elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*\n?.*account that you tried to reach does not exist/i", $body, $match)) {
338
    $result['rule_cat'] = 'unknown';
339
    $result['rule_no'] = '7770';
340
    $result['email'] = $match[1];
341
  } /* rule: dns_unknown
342
   * sample1:
343
   *   Delivery to the following recipient failed permanently:
344
   *
@@ 397-402 (lines=6) @@
394
   *   <[email protected]>:
395
   *   Unable to switch to /var/vpopmail/domains/domain.com: input/output error. (#4.3.0)
396
   */
397
  elseif (preg_match("/input\/output error/i", $body, $match)) {
398
    $result['rule_cat'] = 'internal_error';
399
    $result['rule_no'] = '0172';
400
    $result['bounce_type'] = 'hard';
401
    $result['remove'] = 1;
402
  } /* rule: internal_error
403
   * sample:
404
   *   <[email protected]>:
405
   *   can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350
@@ 407-412 (lines=6) @@
404
   *   <[email protected]>:
405
   *   can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350
406
   */
407
  elseif (preg_match('/can not open new email file/i', $body, $match)) {
408
    $result['rule_cat'] = 'internal_error';
409
    $result['rule_no'] = '0173';
410
    $result['bounce_type'] = 'hard';
411
    $result['remove'] = 1;
412
  } /* rule: defer
413
   * sample:
414
   *   <[email protected]>:
415
   *   111.111.111.111 failed after I sent the message.
@@ 425-429 (lines=5) @@
422
   * sample:
423
   *   AutoReply message from [email protected]
424
   */
425
  elseif (preg_match("/^AutoReply message from (\S+@\S+\w)/i", $body, $match)) {
426
    $result['rule_cat'] = 'autoreply';
427
    $result['rule_no'] = '0167';
428
    $result['email'] = $match[1];
429
  } /* rule: block
430
   * sample:
431
   *   Delivery to the following recipient failed permanently:
432
   *     [email protected]
@@ 609-613 (lines=5) @@
606
     * sample:   DSN Message only
607
     * User quota exceeded: SMTP <[email protected]>
608
     */
609
    if (preg_match("/quota exceed.*<(\S+@\S+\w)>/is", $dsn_msg, $match)) {
610
      $result['rule_cat'] = 'full';
611
      $result['rule_no'] = '0161';
612
      $result['email'] = $match[1];
613
    }
614
  } else {
615
    /* action could be one of them as RFC:1894
616
     * "failed" / "delayed" / "delivered" / "relayed" / "expanded"