Code Duplication    Length = 4-4 lines in 28 locations

src/BounceMailHandler/phpmailer-bmh_rules.php 28 locations

@@ 134-137 (lines=4) @@
131
   *   111.111.111.111 does not like recipient.
132
   *   Remote host said: 550 User unknown
133
   */
134
  elseif (preg_match("/user\s+unknown/i", $body, $match)) {
135
    $result['rule_cat'] = 'unknown';
136
    $result['rule_no'] = '0236';
137
  } /* rule: unknown
138
   * sample:
139
   *
140
   */
@@ 141-144 (lines=4) @@
138
   * sample:
139
   *
140
   */
141
  elseif (preg_match("/unknown\s+user/i", $body, $match)) {
142
    $result['rule_cat'] = 'unknown';
143
    $result['rule_no'] = '0249';
144
  } /* rule: unknown
145
   * sample:
146
   *   <[email protected]>:
147
   *   Sorry, no mailbox here by that name. vpopmail (#5.1.1)
@@ 149-152 (lines=4) @@
146
   *   <[email protected]>:
147
   *   Sorry, no mailbox here by that name. vpopmail (#5.1.1)
148
   */
149
  elseif (preg_match("/no\s+mailbox/i", $body, $match)) {
150
    $result['rule_cat'] = 'unknown';
151
    $result['rule_no'] = '0157';
152
  } /* rule: unknown
153
   * sample:
154
   *   [email protected]<br>
155
   *   local: Sorry, can't find user's mailbox. (#5.1.1)<br>
@@ 157-160 (lines=4) @@
154
   *   [email protected]<br>
155
   *   local: Sorry, can't find user's mailbox. (#5.1.1)<br>
156
   */
157
  elseif (preg_match("/can't\s+find.*mailbox/i", $body, $match)) {
158
    $result['rule_cat'] = 'unknown';
159
    $result['rule_no'] = '0164';
160
  } /* rule: unknown
161
   * sample:
162
   *   ##########################################################
163
   *   #  This is an automated response from a mail delivery    #
@@ 181-184 (lines=4) @@
178
   *   ????????????????:
179
   *   [email protected] : ????, ?????.
180
   */
181
  elseif (preg_match('/=D5=CA=BA=C5=B2=BB=B4=E6=D4=DA/i', $body, $match)) {
182
    $result['rule_cat'] = 'unknown';
183
    $result['rule_no'] = '0174';
184
  } /* rule: unknown
185
   * sample:
186
   *   [email protected]
187
   *   Unrouteable address
@@ 189-192 (lines=4) @@
186
   *   [email protected]
187
   *   Unrouteable address
188
   */
189
  elseif (preg_match("/Unrouteable\s+address/i", $body, $match)) {
190
    $result['rule_cat'] = 'unknown';
191
    $result['rule_no'] = '0179';
192
  } /* rule: unknown
193
   * sample:
194
   *   Delivery to the following recipients failed.
195
   *   [email protected]
@@ 209-212 (lines=4) @@
206
   *   [email protected]
207
   *   unknown local-part "xxxxx" in domain "yourdomain.com"
208
   */
209
  elseif (preg_match("/unknown\s+local-part/i", $body, $match)) {
210
    $result['rule_cat'] = 'unknown';
211
    $result['rule_no'] = '0232';
212
  } /* rule: unknown
213
   * sample:
214
   *   <[email protected]>:
215
   *   111.111.111.11 does not like recipient.
@@ 239-242 (lines=4) @@
236
   * sample:
237
   *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
238
   */
239
  elseif (preg_match('/not unique.\s+Several matches found/i', $body, $match)) {
240
    $result['rule_cat'] = 'unknown';
241
    $result['rule_no'] = '0254';
242
  } /* rule: full
243
   * sample 1:
244
   *   <[email protected]>:
245
   *   This account is over quota and unable to receive mail.
@@ 251-254 (lines=4) @@
248
   *   Warning: undefined mail delivery mode: normal (ignored).
249
   *   The users mailfolder is over the allowed quota (size). (#5.2.2)
250
   */
251
  elseif (preg_match('/over.*quota/i', $body, $match)) {
252
    $result['rule_cat'] = 'full';
253
    $result['rule_no'] = '0182';
254
  } /* rule: full
255
   * sample:
256
   *   ----- Transcript of session follows -----
257
   *   mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
@@ 270-273 (lines=4) @@
267
   *   <[email protected]>:
268
   *   - User disk quota exceeded. (#4.3.0)
269
   */
270
  elseif (preg_match("/quota\s+exceeded/i", $body, $match)) {
271
    $result['rule_cat'] = 'full';
272
    $result['rule_no'] = '0158';
273
  } /* rule: full
274
   * sample:
275
   *   [email protected]
276
   *   mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):
@@ 278-281 (lines=4) @@
275
   *   [email protected]
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('/mailbox.*full/i', $body, $match)) {
279
    $result['rule_cat'] = 'full';
280
    $result['rule_no'] = '0166';
281
  } /* rule: full
282
   * sample:
283
   *   The message to [email protected] is bounced because : Quota exceed the hard limit
284
   */
@@ 293-296 (lines=4) @@
290
   * sample:
291
   *   Message rejected. Not enough storage space in user's mailbox to accept message.
292
   */
293
  elseif (preg_match("/not\s+enough\s+storage\s+space/i", $body, $match)) {
294
    $result['rule_cat'] = 'full';
295
    $result['rule_no'] = '0253';
296
  } /* rule: inactive
297
   * sample:
298
   *   [email protected]<br>
299
   *   553 user is inactive (eyou mta)
@@ 301-304 (lines=4) @@
298
   *   [email protected]<br>
299
   *   553 user is inactive (eyou mta)
300
   */
301
  elseif (preg_match('/user is inactive/i', $body, $match)) {
302
    $result['rule_cat'] = 'inactive';
303
    $result['rule_no'] = '0171';
304
  } /*
305
   * <[email protected]> is restricted
306
   */
307
  elseif (preg_match("/(\S+@\S+\w).*n? is restricted/i", $body, $match)) {
@@ 315-318 (lines=4) @@
312
   * sample:
313
   *   [email protected] [Inactive account]
314
   */
315
  elseif (preg_match('/inactive account/i', $body, $match)) {
316
    $result['rule_cat'] = 'inactive';
317
    $result['rule_no'] = '0181';
318
  } /*
319
   *<[email protected]>: host mx3.HOTMAIL.COM said: 550
320
   * Requested action not taken: mailbox unavailable (in reply to RCPT TO command)
321
   */
@@ 359-362 (lines=4) @@
356
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
357
   *   [pop.b.c (1): Connection dropped]
358
   */
359
  elseif (preg_match('/Technical details of permanent failure:\s+TEMP_FAILURE: Could not initiate SMTP conversation with any hosts/i', $body, $match)) {
360
    $result['rule_cat'] = 'dns_unknown';
361
    $result['rule_no'] = '0251';
362
  } /* rule: delayed
363
   * sample:
364
   *   Delivery to the following recipient has been delayed:
365
   *
@@ 374-377 (lines=4) @@
371
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
372
   *   [b.c (50): Connection timed out]
373
   */
374
  elseif (preg_match('/Technical details of temporary failure:\s+TEMP_FAILURE: Could not initiate SMTP conversation with any hosts/i', $body, $match)) {
375
    $result['rule_cat'] = 'delayed';
376
    $result['rule_no'] = '0252';
377
  } /* rule: delayed
378
   * sample:
379
   *   Delivery to the following recipient has been delayed:
380
   *
@@ 389-392 (lines=4) @@
386
   *   TEMP_FAILURE: The recipient server did not accept our requests to connect. Learn more at ...
387
   *   [b.c (10): Connection dropped]
388
   */
389
  elseif (preg_match('/Technical details of temporary failure:\s+TEMP_FAILURE: The recipient server did not accept our requests to connect./i', $body, $match)) {
390
    $result['rule_cat'] = 'delayed';
391
    $result['rule_no'] = '0256';
392
  } /* rule: internal_error
393
   * sample:
394
   *   <[email protected]>:
395
   *   Unable to switch to /var/vpopmail/domains/domain.com: input/output error. (#4.3.0)
@@ 418-421 (lines=4) @@
415
   *   111.111.111.111 failed after I sent the message.
416
   *   Remote host said: 451 mta283.mail.scd.yahoo.com Resources temporarily unavailable. Please try again later [#4.16.5].
417
   */
418
  elseif (preg_match('/Resources temporarily unavailable/i', $body, $match)) {
419
    $result['rule_cat'] = 'defer';
420
    $result['rule_no'] = '0163';
421
  } /* rule: autoreply
422
   * sample:
423
   *   AutoReply message from [email protected]
424
   */
@@ 436-439 (lines=4) @@
433
   *   Technical details of permanent failure:
434
   *   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.
435
   */
436
  elseif (preg_match("/Your message \([^)]+\) was blocked by/i", $body, $match)) {
437
    $result['rule_cat'] = 'antispam';
438
    $result['rule_no'] = '0250';
439
  } /* rule: content_reject
440
   * sample:
441
   *   Failed to deliver to '<[email protected]>'
442
   *   Messages without To: fields are not accepted here
@@ 444-447 (lines=4) @@
441
   *   Failed to deliver to '<[email protected]>'
442
   *   Messages without To: fields are not accepted here
443
   */
444
  elseif (preg_match("/Messages\s+without\s+\S+\s+fields\s+are\s+not\s+accepted\s+here/i", $body, $match)) {
445
    $result['rule_cat'] = 'content_reject';
446
    $result['rule_no'] = '0248';
447
  }  /* rule: inactive
448
   * sample:
449
   *   <[email protected]>:
450
   *   This address no longer accepts mail.
@@ 452-455 (lines=4) @@
449
   *   <[email protected]>:
450
   *   This address no longer accepts mail.
451
   */
452
  elseif (preg_match("/(?:alias|account|recipient|address|email|mailbox|user).*no\s+longer\s+accepts\s+mail/i", $body, $match)) {
453
    $result['rule_cat'] = 'inactive';
454
    $result['rule_no'] = '0235';
455
  } /* rule: western chars only
456
   * sample:
457
   *   <[email protected]>:
458
   *   The user does not accept email in non-Western (non-Latin) character sets.
@@ 460-463 (lines=4) @@
457
   *   <[email protected]>:
458
   *   The user does not accept email in non-Western (non-Latin) character sets.
459
   */
460
  elseif (preg_match("/does not accept[^\r\n]*non-Western/i", $body, $match)) {
461
    $result['rule_cat'] = 'latin_only';
462
    $result['rule_no'] = '0043';
463
  } /* rule: unknown
464
   * sample:
465
   *   554 delivery error
466
   *   This user doesn't have a yahoo.com account
@@ 468-471 (lines=4) @@
465
   *   554 delivery error
466
   *   This user doesn't have a yahoo.com account
467
   */
468
  elseif (preg_match("/554.*delivery error.*this user.*doesn't have.*account/is", $body, $match)) {
469
    $result['rule_cat'] = 'unknown';
470
    $result['rule_no'] = '0044';
471
  } /* rule: unknown
472
   * sample:
473
   *   550 hotmail.com
474
   */
@@ 475-478 (lines=4) @@
472
   * sample:
473
   *   550 hotmail.com
474
   */
475
  elseif (preg_match('/550.*Requested.*action.*not.*taken:.*mailbox.*unavailable/is', $body, $match)) {
476
    $result['rule_cat'] = 'unknown';
477
    $result['rule_no'] = '0045';
478
  } /* rule: unknown
479
   * sample:
480
   *   550 5.1.1 aim.com
481
   */
@@ 482-485 (lines=4) @@
479
   * sample:
480
   *   550 5.1.1 aim.com
481
   */
482
  elseif (preg_match("/550 5\.1\.1.*Recipient address rejected/is", $body, $match)) {
483
    $result['rule_cat'] = 'unknown';
484
    $result['rule_no'] = '0046';
485
  } /* rule: unknown
486
   * sample:
487
   *   550 .* (in reply to end of DATA command)
488
   */
@@ 489-492 (lines=4) @@
486
   * sample:
487
   *   550 .* (in reply to end of DATA command)
488
   */
489
  elseif (preg_match('/550.*in reply to end of DATA command/i', $body, $match)) {
490
    $result['rule_cat'] = 'unknown';
491
    $result['rule_no'] = '0047';
492
  } /* rule: unknown
493
   * sample:
494
   *   550 .* (in reply to RCPT TO command)
495
   */
@@ 496-499 (lines=4) @@
493
   * sample:
494
   *   550 .* (in reply to RCPT TO command)
495
   */
496
  elseif (preg_match('/550.*in reply to RCPT TO command/i', $body, $match)) {
497
    $result['rule_cat'] = 'unknown';
498
    $result['rule_no'] = '0048';
499
  } /* rule: dns_unknown
500
   * sample:
501
   *    [email protected]:
502
   *      unrouteable mail domain "b.c"
@@ 504-507 (lines=4) @@
501
   *    [email protected]:
502
   *      unrouteable mail domain "b.c"
503
   */
504
  elseif (preg_match("/unrouteable\s+mail\s+domain/i", $body, $match)) {
505
    $result['rule_cat'] = 'dns_unknown';
506
    $result['rule_no'] = '0247';
507
  }
508
509
  if ($result['rule_no'] !== '0000' && $result['email'] === '') {
510
    $preBody = substr($body, 0, strpos($body, $match[0]));