Code Duplication    Length = 4-4 lines in 29 locations

include/phpmailer_bmh/phpmailer-bmh_rules.php 29 locations

@@ 107-110 (lines=4) @@
104
   *   [email protected]
105
   *   no such address here
106
   */
107
    elseif (\preg_match("/no\s+such\s+address\s+here/i", $body, $match)) {
108
        $result['rule_cat'] = 'unknown';
109
        $result['rule_no'] = '0237';
110
    } /* Gmail Bounce Error
111
   * rule: unknown
112
   * sample:
113
   *   Delivery to the following recipient failed permanently:
@@ 139-142 (lines=4) @@
136
   *   111.111.111.111 does not like recipient.
137
   *   Remote host said: 550 User unknown
138
   */
139
    elseif (\preg_match("/user\s+unknown/i", $body, $match)) {
140
        $result['rule_cat'] = 'unknown';
141
        $result['rule_no'] = '0236';
142
    } /* rule: unknown
143
   * sample:
144
   *
145
   */
@@ 146-149 (lines=4) @@
143
   * sample:
144
   *
145
   */
146
    elseif (\preg_match("/unknown\s+user/i", $body, $match)) {
147
        $result['rule_cat'] = 'unknown';
148
        $result['rule_no'] = '0249';
149
    } /* rule: unknown
150
   * sample:
151
   *   <[email protected]>:
152
   *   Sorry, no mailbox here by that name. vpopmail (#5.1.1)
@@ 154-157 (lines=4) @@
151
   *   <[email protected]>:
152
   *   Sorry, no mailbox here by that name. vpopmail (#5.1.1)
153
   */
154
    elseif (\preg_match("/no\s+mailbox/i", $body, $match)) {
155
        $result['rule_cat'] = 'unknown';
156
        $result['rule_no'] = '0157';
157
    } /* rule: unknown
158
   * sample:
159
   *   [email protected]<br>
160
   *   local: Sorry, can't find user's mailbox. (#5.1.1)<br>
@@ 162-165 (lines=4) @@
159
   *   [email protected]<br>
160
   *   local: Sorry, can't find user's mailbox. (#5.1.1)<br>
161
   */
162
    elseif (\preg_match("/can't\s+find.*mailbox/i", $body, $match)) {
163
        $result['rule_cat'] = 'unknown';
164
        $result['rule_no'] = '0164';
165
    } /* rule: unknown
166
   * sample:
167
   *   ##########################################################
168
   *   #  This is an automated response from a mail delivery    #
@@ 186-189 (lines=4) @@
183
   *   ????????????????:
184
   *   [email protected] : ????, ?????.
185
   */
186
    elseif (\preg_match('/=D5=CA=BA=C5=B2=BB=B4=E6=D4=DA/i', $body, $match)) {
187
        $result['rule_cat'] = 'unknown';
188
        $result['rule_no'] = '0174';
189
    } /* rule: unknown
190
   * sample:
191
   *   [email protected]
192
   *   Unrouteable address
@@ 194-197 (lines=4) @@
191
   *   [email protected]
192
   *   Unrouteable address
193
   */
194
    elseif (\preg_match("/Unrouteable\s+address/i", $body, $match)) {
195
        $result['rule_cat'] = 'unknown';
196
        $result['rule_no'] = '0179';
197
    } /* rule: unknown
198
   * sample:
199
   *   Delivery to the following recipients failed.
200
   *   [email protected]
@@ 214-217 (lines=4) @@
211
   *   [email protected]
212
   *   unknown local-part "xxxxx" in domain "yourdomain.com"
213
   */
214
    elseif (\preg_match("/unknown\s+local-part/i", $body, $match)) {
215
        $result['rule_cat'] = 'unknown';
216
        $result['rule_no'] = '0232';
217
    } /* rule: unknown
218
   * sample:
219
   *   <[email protected]>:
220
   *   111.111.111.11 does not like recipient.
@@ 244-247 (lines=4) @@
241
   * sample:
242
   *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
243
   */
244
    elseif (\preg_match('/not unique.\s+Several matches found/i', $body, $match)) {
245
        $result['rule_cat'] = 'unknown';
246
        $result['rule_no'] = '0254';
247
    } /* rule: full
248
   * sample 1:
249
   *   <[email protected]>:
250
   *   This account is over quota and unable to receive mail.
@@ 256-259 (lines=4) @@
253
   *   Warning: undefined mail delivery mode: normal (ignored).
254
   *   The users mailfolder is over the allowed quota (size). (#5.2.2)
255
   */
256
    elseif (\preg_match('/over.*quota/i', $body, $match)) {
257
        $result['rule_cat'] = 'full';
258
        $result['rule_no'] = '0182';
259
    } /* rule: full
260
   * sample:
261
   *   ----- Transcript of session follows -----
262
   *   mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
@@ 275-278 (lines=4) @@
272
   *   <[email protected]>:
273
   *   - User disk quota exceeded. (#4.3.0)
274
   */
275
    elseif (\preg_match("/quota\s+exceeded/i", $body, $match)) {
276
        $result['rule_cat'] = 'full';
277
        $result['rule_no'] = '0158';
278
    } /* rule: full
279
   * sample:
280
   *   [email protected]
281
   *   mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):
@@ 283-286 (lines=4) @@
280
   *   [email protected]
281
   *   mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):
282
   */
283
    elseif (\preg_match('/mailbox.*full/i', $body, $match)) {
284
        $result['rule_cat'] = 'full';
285
        $result['rule_no'] = '0166';
286
    } /* rule: full
287
   * sample:
288
   *   The message to [email protected] is bounced because : Quota exceed the hard limit
289
   */
@@ 298-301 (lines=4) @@
295
   * sample:
296
   *   Message rejected. Not enough storage space in user's mailbox to accept message.
297
   */
298
    elseif (\preg_match("/not\s+enough\s+storage\s+space/i", $body, $match)) {
299
        $result['rule_cat'] = 'full';
300
        $result['rule_no'] = '0253';
301
    } /* rule: inactive
302
   * sample:
303
   *   [email protected]<br>
304
   *   553 user is inactive (eyou mta)
@@ 306-309 (lines=4) @@
303
   *   [email protected]<br>
304
   *   553 user is inactive (eyou mta)
305
   */
306
    elseif (\preg_match('/user is inactive/i', $body, $match)) {
307
        $result['rule_cat'] = 'inactive';
308
        $result['rule_no'] = '0171';
309
    } /*
310
   * <[email protected]> is restricted
311
   */
312
    elseif (\preg_match("/(\S+@\S+\w).*n? is restricted/i", $body, $match)) {
@@ 320-323 (lines=4) @@
317
   * sample:
318
   *   [email protected] [Inactive account]
319
   */
320
    elseif (\preg_match('/inactive account/i', $body, $match)) {
321
        $result['rule_cat'] = 'inactive';
322
        $result['rule_no'] = '0181';
323
    } /*
324
   *<[email protected]>: host mx3.HOTMAIL.COM said: 550
325
   * Requested action not taken: mailbox unavailable (in reply to RCPT TO command)
326
   */
@@ 364-367 (lines=4) @@
361
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
362
   *   [pop.b.c (1): Connection dropped]
363
   */
364
    elseif (\preg_match('/Technical details of permanent failure:\s+TEMP_FAILURE: Could not initiate SMTP conversation with any hosts/i', $body, $match)) {
365
        $result['rule_cat'] = 'dns_unknown';
366
        $result['rule_no'] = '0251';
367
    } /* rule: delayed
368
   * sample:
369
   *   Delivery to the following recipient has been delayed:
370
   *
@@ 379-382 (lines=4) @@
376
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
377
   *   [b.c (50): Connection timed out]
378
   */
379
    elseif (\preg_match('/Technical details of temporary failure:\s+TEMP_FAILURE: Could not initiate SMTP conversation with any hosts/i', $body, $match)) {
380
        $result['rule_cat'] = 'delayed';
381
        $result['rule_no'] = '0252';
382
    } /* rule: delayed
383
   * sample:
384
   *   Delivery to the following recipient has been delayed:
385
   *
@@ 394-397 (lines=4) @@
391
   *   TEMP_FAILURE: The recipient server did not accept our requests to connect. Learn more at ...
392
   *   [b.c (10): Connection dropped]
393
   */
394
    elseif (\preg_match('/Technical details of temporary failure:\s+TEMP_FAILURE: The recipient server did not accept our requests to connect./i', $body, $match)) {
395
        $result['rule_cat'] = 'delayed';
396
        $result['rule_no'] = '0256';
397
    } /* rule: internal_error
398
   * sample:
399
   *   <[email protected]>:
400
   *   Unable to switch to /var/vpopmail/domains/domain.com: input/output error. (#4.3.0)
@@ 423-426 (lines=4) @@
420
   *   111.111.111.111 failed after I sent the message.
421
   *   Remote host said: 451 mta283.mail.scd.yahoo.com Resources temporarily unavailable. Please try again later [#4.16.5].
422
   */
423
    elseif (\preg_match('/Resources temporarily unavailable/i', $body, $match)) {
424
        $result['rule_cat'] = 'defer';
425
        $result['rule_no'] = '0163';
426
    } /* rule: autoreply
427
   * sample:
428
   *   AutoReply message from [email protected]
429
   */
@@ 441-444 (lines=4) @@
438
   *   Technical details of permanent failure:
439
   *   PERM_FAILURE: SMTP Error (state 9): 550 5.7.1 Your message (sent through 209.85.132.244) was blocked by ROTA DNSBL. If you are not a spammer, open http://www.rota.lv/DNSBL and follow instructions or call +371 7019029, or send an e-mail message from another address to [email protected] with the blocked sender e-mail name.
440
   */
441
    elseif (\preg_match("/Your message \([^)]+\) was blocked by/i", $body, $match)) {
442
        $result['rule_cat'] = 'antispam';
443
        $result['rule_no'] = '0250';
444
    } /* rule: content_reject
445
   * sample:
446
   *   Failed to deliver to '<[email protected]>'
447
   *   Messages without To: fields are not accepted here
@@ 449-452 (lines=4) @@
446
   *   Failed to deliver to '<[email protected]>'
447
   *   Messages without To: fields are not accepted here
448
   */
449
    elseif (\preg_match("/Messages\s+without\s+\S+\s+fields\s+are\s+not\s+accepted\s+here/i", $body, $match)) {
450
        $result['rule_cat'] = 'content_reject';
451
        $result['rule_no'] = '0248';
452
    }  /* rule: inactive
453
   * sample:
454
   *   <[email protected]>:
455
   *   This address no longer accepts mail.
@@ 457-460 (lines=4) @@
454
   *   <[email protected]>:
455
   *   This address no longer accepts mail.
456
   */
457
    elseif (\preg_match("/(?:alias|account|recipient|address|email|mailbox|user).*no\s+longer\s+accepts\s+mail/i", $body, $match)) {
458
        $result['rule_cat'] = 'inactive';
459
        $result['rule_no'] = '0235';
460
    } /* rule: western chars only
461
   * sample:
462
   *   <[email protected]>:
463
   *   The user does not accept email in non-Western (non-Latin) character sets.
@@ 465-468 (lines=4) @@
462
   *   <[email protected]>:
463
   *   The user does not accept email in non-Western (non-Latin) character sets.
464
   */
465
    elseif (\preg_match("/does not accept[^\r\n]*non-Western/i", $body, $match)) {
466
        $result['rule_cat'] = 'latin_only';
467
        $result['rule_no'] = '0043';
468
    } /* rule: unknown
469
   * sample:
470
   *   554 delivery error
471
   *   This user doesn't have a yahoo.com account
@@ 473-476 (lines=4) @@
470
   *   554 delivery error
471
   *   This user doesn't have a yahoo.com account
472
   */
473
    elseif (\preg_match("/554.*delivery error.*this user.*doesn't have.*account/is", $body, $match)) {
474
        $result['rule_cat'] = 'unknown';
475
        $result['rule_no'] = '0044';
476
    } /* rule: unknown
477
   * sample:
478
   *   550 hotmail.com
479
   */
@@ 480-483 (lines=4) @@
477
   * sample:
478
   *   550 hotmail.com
479
   */
480
    elseif (\preg_match('/550.*Requested.*action.*not.*taken:.*mailbox.*unavailable/is', $body, $match)) {
481
        $result['rule_cat'] = 'unknown';
482
        $result['rule_no'] = '0045';
483
    } /* rule: unknown
484
   * sample:
485
   *   550 5.1.1 aim.com
486
   */
@@ 487-490 (lines=4) @@
484
   * sample:
485
   *   550 5.1.1 aim.com
486
   */
487
    elseif (\preg_match("/550 5\.1\.1.*Recipient address rejected/is", $body, $match)) {
488
        $result['rule_cat'] = 'unknown';
489
        $result['rule_no'] = '0046';
490
    } /* rule: unknown
491
   * sample:
492
   *   550 .* (in reply to end of DATA command)
493
   */
@@ 494-497 (lines=4) @@
491
   * sample:
492
   *   550 .* (in reply to end of DATA command)
493
   */
494
    elseif (\preg_match('/550.*in reply to end of DATA command/i', $body, $match)) {
495
        $result['rule_cat'] = 'unknown';
496
        $result['rule_no'] = '0047';
497
    } /* rule: unknown
498
   * sample:
499
   *   550 .* (in reply to RCPT TO command)
500
   */
@@ 501-504 (lines=4) @@
498
   * sample:
499
   *   550 .* (in reply to RCPT TO command)
500
   */
501
    elseif (\preg_match('/550.*in reply to RCPT TO command/i', $body, $match)) {
502
        $result['rule_cat'] = 'unknown';
503
        $result['rule_no'] = '0048';
504
    } /* rule: dns_unknown
505
   * sample:
506
   *    [email protected]:
507
   *      unrouteable mail domain "b.c"
@@ 509-512 (lines=4) @@
506
   *    [email protected]:
507
   *      unrouteable mail domain "b.c"
508
   */
509
    elseif (\preg_match("/unrouteable\s+mail\s+domain/i", $body, $match)) {
510
        $result['rule_cat'] = 'dns_unknown';
511
        $result['rule_no'] = '0247';
512
    }
513
514
    if ($result['rule_no'] !== '0000' && $result['email'] === '') {
515
        $preBody = \substr($body, 0, \strpos($body, $match[0]));