Code Duplication    Length = 5-6 lines in 13 locations

include/phpmailer_bmh/phpmailer-bmh_rules.php 13 locations

@@ 177-181 (lines=5) @@
174
   *   #        (expanded from: <[email protected]>)         #
175
   *   #                                                        #
176
   */
177
    elseif (\preg_match("/Can't\s+create\s+output.*<(\S+@\S+\w)>/is", $body, $match)) {
178
        $result['rule_cat'] = 'unknown';
179
        $result['rule_no'] = '0169';
180
        $result['email'] = $match[1];
181
    } /* rule: unknown
182
   * sample:
183
   *   ????????????????:
184
   *   [email protected] : ????, ?????.
@@ 202-206 (lines=5) @@
199
   *   Delivery to the following recipients failed.
200
   *   [email protected]
201
   */
202
    elseif (\preg_match("/delivery[^\n\r]+failed\S*\s+(\S+@\S+\w)\s/i", $body, $match)) {
203
        $result['rule_cat'] = 'unknown';
204
        $result['rule_no'] = '0013';
205
        $result['email'] = $match[1];
206
    } /* rule: unknown
207
   * sample:
208
   *   A message that you sent could not be delivered to one or more of its
209
   *   recipients. This is a permanent error. The following address(es) failed:
@@ 223-227 (lines=5) @@
220
   *   111.111.111.11 does not like recipient.
221
   *   Remote host said: 550 Invalid recipient: <[email protected]>
222
   */
223
    elseif (\preg_match("/Invalid.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/is", $body, $match)) {
224
        $result['rule_cat'] = 'unknown';
225
        $result['rule_no'] = '0233';
226
        $result['email'] = $match[1];
227
    } /* rule: unknown
228
   * sample:
229
   *   Sent >>> RCPT TO: <[email protected]>
230
   *   Received <<< 550 [email protected]... No such user
@@ 236-240 (lines=5) @@
233
   *   [email protected]
234
   *   *****************     End of message     ***************
235
   */
236
    elseif (\preg_match("/No\s+such.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/is", $body, $match)) {
237
        $result['rule_cat'] = 'unknown';
238
        $result['rule_no'] = '0234';
239
        $result['email'] = $match[1];
240
    } /* rule: unknown
241
   * sample:
242
   *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
243
   */
@@ 265-269 (lines=5) @@
262
   *   mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
263
   *   554 <[email protected]>... Service unavailable
264
   */
265
    elseif (\preg_match("/quota\s+exceeded.*<(\S+@\S+\w)>/is", $body, $match)) {
266
        $result['rule_cat'] = 'full';
267
        $result['rule_no'] = '0126';
268
        $result['email'] = $match[1];
269
    } /* rule: full
270
   * sample:
271
   *   Hi. This is the qmail-send program at 263.domain.com.
272
   *   <[email protected]>:
@@ 290-294 (lines=5) @@
287
   * sample:
288
   *   The message to [email protected] is bounced because : Quota exceed the hard limit
289
   */
290
    elseif (\preg_match("/The message to (\S+@\S+\w)\s.*bounce.*Quota exceed/i", $body, $match)) {
291
        $result['rule_cat'] = 'full';
292
        $result['rule_no'] = '0168';
293
        $result['email'] = $match[1];
294
    } /* rule: full
295
   * sample:
296
   *   Message rejected. Not enough storage space in user's mailbox to accept message.
297
   */
@@ 312-316 (lines=5) @@
309
    } /*
310
   * <[email protected]> is restricted
311
   */
312
    elseif (\preg_match("/(\S+@\S+\w).*n? is restricted/i", $body, $match)) {
313
        $result['rule_cat'] = 'inactive';
314
        $result['rule_no'] = '0201';
315
        $result['email'] = $match[1];
316
    } /* rule: inactive
317
   * sample:
318
   *   [email protected] [Inactive account]
319
   */
@@ 327-331 (lines=5) @@
324
   *<[email protected]>: host mx3.HOTMAIL.COM said: 550
325
   * Requested action not taken: mailbox unavailable (in reply to RCPT TO command)
326
   */
327
    elseif (\preg_match("/<(\S+@\S+\w)>.*\n.*mailbox unavailable/i", $body, $match)) {
328
        $result['rule_cat'] = 'unknown';
329
        $result['rule_no'] = '124';
330
        $result['email'] = $match[1];
331
    } /*
332
   * rule: mailbox unknown;
333
   * sample:
334
   * [email protected]
@@ 342-346 (lines=5) @@
339
   * http://support.google.com/mail/bin/answer.py?answer=6596 n7si4762785wiy.46
340
   * (in reply to RCPT TO command)
341
   */
342
    elseif (\preg_match("/<(\S+@\S+\w)>.*\n?.*\n?.*account that you tried to reach does not exist/i", $body, $match)) {
343
        $result['rule_cat'] = 'unknown';
344
        $result['rule_no'] = '7770';
345
        $result['email'] = $match[1];
346
    } /* rule: dns_unknown
347
   * sample1:
348
   *   Delivery to the following recipient failed permanently:
349
   *
@@ 402-407 (lines=6) @@
399
   *   <[email protected]>:
400
   *   Unable to switch to /var/vpopmail/domains/domain.com: input/output error. (#4.3.0)
401
   */
402
    elseif (\preg_match("/input\/output error/i", $body, $match)) {
403
        $result['rule_cat'] = 'internal_error';
404
        $result['rule_no'] = '0172';
405
        $result['bounce_type'] = 'hard';
406
        $result['remove'] = 1;
407
    } /* rule: internal_error
408
   * sample:
409
   *   <[email protected]>:
410
   *   can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350
@@ 412-417 (lines=6) @@
409
   *   <[email protected]>:
410
   *   can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350
411
   */
412
    elseif (\preg_match('/can not open new email file/i', $body, $match)) {
413
        $result['rule_cat'] = 'internal_error';
414
        $result['rule_no'] = '0173';
415
        $result['bounce_type'] = 'hard';
416
        $result['remove'] = 1;
417
    } /* rule: defer
418
   * sample:
419
   *   <[email protected]>:
420
   *   111.111.111.111 failed after I sent the message.
@@ 430-434 (lines=5) @@
427
   * sample:
428
   *   AutoReply message from [email protected]
429
   */
430
    elseif (\preg_match("/^AutoReply message from (\S+@\S+\w)/i", $body, $match)) {
431
        $result['rule_cat'] = 'autoreply';
432
        $result['rule_no'] = '0167';
433
        $result['email'] = $match[1];
434
    } /* rule: block
435
   * sample:
436
   *   Delivery to the following recipient failed permanently:
437
   *     [email protected]
@@ 616-620 (lines=5) @@
613
         * sample:   DSN Message only
614
         * User quota exceeded: SMTP <[email protected]>
615
         */
616
        if (\preg_match("/quota exceed.*<(\S+@\S+\w)>/is", $dsn_msg, $match)) {
617
            $result['rule_cat'] = 'full';
618
            $result['rule_no'] = '0161';
619
            $result['email'] = $match[1];
620
        }
621
    } else {
622
        /* action could be one of them as RFC:1894
623
         * "failed" / "delayed" / "delivered" / "relayed" / "expanded"