Code Duplication    Length = 5-5 lines in 34 locations

include/phpmailer_bmh/phpmailer-bmh_rules.php 34 locations

@@ 92-96 (lines=5) @@
89
   * sample:
90
   * Delivery to the following recipients failed.
91
   * [email protected]
92
   */ elseif (preg_match("/delivery[^\n\r]+failed\S*\s+(\S+@\S+\w)\s/is", $body, $match)) {
93
        $result['rule_cat'] = 'unknown';
94
        $result['rule_no']  = '0013';
95
        $result['email']    = $match[1];
96
    } /*
97
   * rule: western chars only
98
   * sample:
99
   * <[email protected]>:
@@ 101-105 (lines=5) @@
98
   * sample:
99
   * <[email protected]>:
100
   * The user does not accept email in non-Western (non-Latin) character sets.
101
   */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*does not accept[^\r\n]*non-Western/i", $body, $match)) {
102
        $result['rule_cat'] = 'latin_only';
103
        $result['rule_no']  = '0043';
104
        $result['email']    = $match[1];
105
    } /*
106
   * rule: mailbox full;
107
   * sample:
108
   *   ----- Transcript of session follows -----
@@ 111-115 (lines=5) @@
108
   *   ----- Transcript of session follows -----
109
   * mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
110
   * 554 <[email protected]>... Service unavailable
111
   */ elseif (preg_match("/quota exceeded.*\n?.*<(\S+@\S+\w)>/i", $body, $match)) {
112
        $result['rule_cat'] = 'full';
113
        $result['rule_no']  = '0126';
114
        $result['email']    = $match[1];
115
    } /*
116
   * rule: mailbox unknown;
117
   * sample:
118
   * <[email protected]>:
@@ 120-124 (lines=5) @@
117
   * sample:
118
   * <[email protected]>:
119
   * Sorry, no mailbox here by that name. vpopmail (#5.1.1)
120
   */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*no mailbox/i", $body, $match)) {
121
        $result['rule_cat'] = 'unknown';
122
        $result['rule_no']  = '0157';
123
        $result['email']    = $match[1];
124
    } /*
125
   * rule: mailbox full;
126
   * sample:
127
   * Hi. This is the qmail-send program at 263.domain.com.
@@ 130-134 (lines=5) @@
127
   * Hi. This is the qmail-send program at 263.domain.com.
128
   * <[email protected]>:
129
   * - User disk quota exceeded. (#4.3.0)
130
   */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*quota exceeded/i", $body, $match)) {
131
        $result['rule_cat'] = 'full';
132
        $result['rule_no']  = '0158';
133
        $result['email']    = $match[1];
134
    } /*
135
   * rule: defer
136
   * sample:
137
   * <[email protected]>:
@@ 140-144 (lines=5) @@
137
   * <[email protected]>:
138
   * 111.111.111.111 failed after I sent the message.
139
   * Remote host said: 451 mta283.mail.scd.yahoo.com Resources temporarily unavailable. Please try again later [#4.16.5].
140
   */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*\n?.*Resources temporarily unavailable/i", $body, $match)) {
141
        $result['rule_cat'] = 'defer';
142
        $result['rule_no']  = '0163';
143
        $result['email']    = $match[1];
144
    } /*
145
   * rule: mailbox unknown;
146
   * sample:
147
   * [email protected]<br>
@@ 149-153 (lines=5) @@
146
   * sample:
147
   * [email protected]<br>
148
   * local: Sorry, can't find user's mailbox. (#5.1.1)<br>
149
   */ elseif (preg_match("/(\S+@\S+\w)<br>.*\n?.*\n?.*can't find.*mailbox/i", $body, $match)) {
150
        $result['rule_cat'] = 'unknown';
151
        $result['rule_no']  = '0164';
152
        $result['email']    = $match[1];
153
    } /*
154
   * rule: mailbox full;
155
   * sample:
156
   * [email protected]
@@ 158-162 (lines=5) @@
155
   * sample:
156
   * [email protected]
157
   * mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):
158
   */ elseif (preg_match("/\s(\S+@\S+\w)\s.*\n?.*mailbox.*full/i", $body, $match)) {
159
        $result['rule_cat'] = 'full';
160
        $result['rule_no']  = '0166';
161
        $result['email']    = $match[1];
162
    } /*
163
   * rule: autoreply
164
   * sample:
165
   * AutoReply message from [email protected]
@@ 166-170 (lines=5) @@
163
   * rule: autoreply
164
   * sample:
165
   * AutoReply message from [email protected]
166
   */ elseif (preg_match("/^AutoReply message from (\S+@\S+\w)/i", $body, $match)) {
167
        $result['rule_cat'] = 'autoreply';
168
        $result['rule_no']  = '0167';
169
        $result['email']    = $match[1];
170
    } /*
171
   * rule: mailbox full;
172
   * sample:
173
   * The message to [email protected] is bounced because : Quota exceed the hard limit
@@ 174-178 (lines=5) @@
171
   * rule: mailbox full;
172
   * sample:
173
   * The message to [email protected] is bounced because : Quota exceed the hard limit
174
   */ elseif (preg_match("/The message to (\S+@\S+\w)\s.*bounce.*Quota exceed/i", $body, $match)) {
175
        $result['rule_cat'] = 'full';
176
        $result['rule_no']  = '0168';
177
        $result['email']    = $match[1];
178
    } /*
179
   * rule: mailbox unknown;
180
   * sample:
181
   *     ##########################################################
@@ 190-194 (lines=5) @@
187
   *     #        (reason: Can't create output)                   #
188
   *     #        (expanded from: <[email protected]>)         #
189
   *     #                                                        #
190
   */ elseif (preg_match("/Can't create output.*\n?.*<(\S+@\S+\w)>/i", $body, $match)) {
191
        $result['rule_cat'] = 'unknown';
192
        $result['rule_no']  = '0169';
193
        $result['email']    = $match[1];
194
    } /*
195
   * rule: inactive
196
   * sample:
197
   * [email protected]<br>
@@ 199-203 (lines=5) @@
196
   * sample:
197
   * [email protected]<br>
198
   * 553 user is inactive (eyou mta)
199
   */ elseif (preg_match("/(\S+@\S+\w)<br>.*\n?.*\n?.*user is inactive/i", $body, $match)) {
200
        $result['rule_cat'] = 'inactive';
201
        $result['rule_no']  = '0171';
202
        $result['email']    = $match[1];
203
    } /*
204
   * rule: internal_error
205
   * sample:
206
   * <[email protected]>:
@@ 230-234 (lines=5) @@
227
   * sample:
228
   * ????????????????:
229
   * [email protected] : ????, ?????.
230
   */ elseif (preg_match("/(\S+@\S+\w).*=D5=CA=BA=C5=B2=BB=B4=E6=D4=DA/i", $body, $match)) {
231
        $result['rule_cat'] = 'unknown';
232
        $result['rule_no']  = '0174';
233
        $result['email']    = $match[1];
234
    } /*
235
   * rule: mailbox unknown;
236
   * sample:
237
   * [email protected]
@@ 239-243 (lines=5) @@
236
   * sample:
237
   * [email protected]
238
   * Unrouteable address
239
   */ elseif (preg_match("/(\S+@\S+\w).*\n?.*Unrouteable address/i", $body, $match)) {
240
        $result['rule_cat'] = 'unknown';
241
        $result['rule_no']  = '0179';
242
        $result['email']    = $match[1];
243
    } /*
244
   * rule: inactive
245
   * sample:
246
   * [email protected] [Inactive account]
@@ 247-251 (lines=5) @@
244
   * rule: inactive
245
   * sample:
246
   * [email protected] [Inactive account]
247
   */ elseif (preg_match("/(\S+@\S+\w).*inactive account/i", $body, $match)) {
248
        $result['rule_cat'] = 'inactive';
249
        $result['rule_no']  = '0181';
250
        $result['email']    = $match[1];
251
    } /*
252
   * rule: full
253
   * sample 1:
254
   * <[email protected]>:
@@ 260-264 (lines=5) @@
257
   * <[email protected]>:
258
   * Warning: undefined mail delivery mode: normal (ignored).
259
   * The users mailfolder is over the allowed quota (size). (#5.2.2)
260
   */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*\n?.*over.*quota/i", $body, $match)) {
261
        $result['rule_cat'] = 'full';
262
        $result['rule_no']  = '0182';
263
        $result['email']    = $match[1];
264
    } /*
265
   * rule: mailbox unknow;
266
   * sample:
267
   * A message that you sent could not be delivered to one or more of its^M
@@ 272-276 (lines=5) @@
269
   * ^M
270
   * [email protected]^M
271
   * unknown local-part "xxxxx" in domain "yourdomain.com"^M
272
   */ elseif (preg_match("/(\S+@\S+\w).*\n?.*unknown local-part/i", $body, $match)) {
273
        $result['rule_cat'] = 'unknown';
274
        $result['rule_no']  = '0232';
275
        $result['email']    = $match[1];
276
    } /*
277
   * rule: mailbox unknow;
278
   * sample:
279
   * <[email protected]>:^M
@@ 282-286 (lines=5) @@
279
   * <[email protected]>:^M
280
   * 111.111.111.11 does not like recipient.^M
281
   * Remote host said: 550 Invalid recipient: <[email protected]>^M
282
   */ elseif (preg_match("/Invalid.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/i", $body, $match)) {
283
        $result['rule_cat'] = 'unknown';
284
        $result['rule_no']  = '0233';
285
        $result['email']    = $match[1];
286
    } /*
287
   * rule: mailbox unknow;
288
   * sample:
289
   * Sent >>> RCPT TO: <[email protected]>^M
@@ 295-299 (lines=5) @@
292
   * Could not deliver mail to this user.^M
293
   * [email protected]^M
294
   * *****************     End of message     ***************^M
295
   */ elseif (preg_match("/\s(\S+@\S+\w).*No such.*(?:alias|account|recipient|address|email|mailbox|user)>/i", $body, $match)) {
296
        $result['rule_cat'] = 'unknown';
297
        $result['rule_no']  = '0234';
298
        $result['email']    = $match[1];
299
    } /*
300
   * rule: mailbox unknow;
301
   * sample:
302
   * <[email protected]>:^M
@@ 304-308 (lines=5) @@
301
   * sample:
302
   * <[email protected]>:^M
303
   * This address no longer accepts mail.
304
   */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*(?:alias|account|recipient|address|email|mailbox|user).*no.*accept.*mail>/i", $body, $match)) {
305
        $result['rule_cat'] = 'unknown';
306
        $result['rule_no']  = '0235';
307
        $result['email']    = $match[1];
308
    } /*
309
   * <[email protected]>:
310
   * 111.111.111.111 does not like recipient.
311
   * Remote host said: 550 User unknown
@@ 312-316 (lines=5) @@
309
   * <[email protected]>:
310
   * 111.111.111.111 does not like recipient.
311
   * Remote host said: 550 User unknown
312
   */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*\n?.*user unknown/i", $body, $match)) {
313
        $result['rule_cat'] = 'unknown';
314
        $result['rule_no']  = '0236';
315
        $result['email']    = $match[1];
316
    } /*
317
   * rule: mailbox unknown;
318
   * sample:
319
   * [email protected]
@@ 321-325 (lines=5) @@
318
   * sample:
319
   * [email protected]
320
   * no such address here
321
   */ elseif (preg_match("/(\S+@\S+\w).*\n?.*no such address here/i", $body, $match)) {
322
        $result['rule_cat'] = 'unknown';
323
        $result['rule_no']  = '0237';
324
        $result['email']    = $match[1];
325
    }
326
327
    //rules added by gofffy
328
    /*
@@ 332-336 (lines=5) @@
329
    * rule: connection refused
330
    * <[email protected]>: connect to yourdomain.com[174.137.125.47]:25: Connection
331
    * refused
332
    */ elseif (preg_match("/<(\S+@\S+\w)>.*connect to.*Connection.*\n?.*refused/i", $body, $match)) {
333
        $result['rule_cat'] = 'unknown';
334
        $result['rule_no']  = '0300';
335
        $result['email']    = $match[1];
336
    } /*
337
  * rule: host or domain name not found
338
  * <[email protected]>: Host or domain name not found.
339
  */ elseif (preg_match("/<(\S+@\S+\w)>.*host or domain name not found/i", $body, $match)) {
@@ 339-343 (lines=5) @@
336
    } /*
337
  * rule: host or domain name not found
338
  * <[email protected]>: Host or domain name not found.
339
  */ elseif (preg_match("/<(\S+@\S+\w)>.*host or domain name not found/i", $body, $match)) {
340
        $result['rule_cat'] = 'unknown';
341
        $result['rule_no']  = '0301';
342
        $result['email']    = $match[1];
343
    } /*
344
  * rule: mailbox full
345
  * <[email protected]>:
346
  *.....said: 550 sorry this mailbox is over
@@ 348-352 (lines=5) @@
345
  * <[email protected]>:
346
  *.....said: 550 sorry this mailbox is over
347
  *  quota.....
348
  */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*mailbox is over.*\n?.*quota/i", $body, $match)) {
349
        $result['rule_cat'] = 'full';
350
        $result['rule_no']  = '0302';
351
        $result['email']    = $match[1];
352
    } /*
353
  * rule: user unknown
354
  * <[email protected]>: .... said: 550 5.1.1 User
355
  *  unknown (in reply to RCPT TO command).....
@@ 356-360 (lines=5) @@
353
  * rule: user unknown
354
  * <[email protected]>: .... said: 550 5.1.1 User
355
  *  unknown (in reply to RCPT TO command).....
356
  */ elseif (preg_match("/<(\S+@\S+\w)>.*user.*\n?.*unknown/i", $body, $match)) {
357
        $result['rule_cat'] = 'unknown';
358
        $result['rule_no']  = '0303';
359
        $result['email']    = $match[1];
360
    } /*
361
  * rule: user unknown
362
  * <[email protected]>: .... said: 550 Requested
363
    action not taken: mailbox unavailable (in reply to RCPT TO command).....
@@ 364-368 (lines=5) @@
361
  * rule: user unknown
362
  * <[email protected]>: .... said: 550 Requested
363
    action not taken: mailbox unavailable (in reply to RCPT TO command).....
364
  */ elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*mailbox unavailable/i", $body, $match)) {
365
        $result['rule_cat'] = 'unknown';
366
        $result['rule_no']  = '0304';
367
        $result['email']    = $match[1];
368
    } /*
369
  * rule: user unknown
370
  * <[email protected]>: .... Command rejected (in reply to RCPT TO command).....
371
  */ elseif (preg_match("/<(\S+@\S+\w)>.*command rejected/i", $body, $match)) {
@@ 371-375 (lines=5) @@
368
    } /*
369
  * rule: user unknown
370
  * <[email protected]>: .... Command rejected (in reply to RCPT TO command).....
371
  */ elseif (preg_match("/<(\S+@\S+\w)>.*command rejected/i", $body, $match)) {
372
        $result['rule_cat'] = 'command_reject';
373
        $result['rule_no']  = '0305';
374
        $result['email']    = $match[1];
375
    } /*
376
  * rule: user unknown
377
  * <[email protected]>: .... said: 550 No
378
    such local user, unauthenticated relaying denied (in reply to RCPT TO
@@ 380-384 (lines=5) @@
377
  * <[email protected]>: .... said: 550 No
378
    such local user, unauthenticated relaying denied (in reply to RCPT TO
379
    command).....
380
  */ elseif (preg_match("/<(\S+@\S+\w)>.*550 no.*\n?.*such local user/i", $body, $match)) {
381
        $result['rule_cat'] = 'unknown';
382
        $result['rule_no']  = '0306';
383
        $result['email']    = $match[1];
384
    } /*
385
  * rule: user unknown
386
  * <[email protected]>: host ... said: 550 5.1.1
387
    unknown or illegal alias: ... (in reply to RCPT TO command).....
@@ 388-392 (lines=5) @@
385
  * rule: user unknown
386
  * <[email protected]>: host ... said: 550 5.1.1
387
    unknown or illegal alias: ... (in reply to RCPT TO command).....
388
  */ elseif (preg_match("/<(\S+@\S+\w)>.*550.*\n?.*unknown or illegal alias/i", $body, $match)) {
389
        $result['rule_cat'] = 'unknown';
390
        $result['rule_no']  = '0307';
391
        $result['email']    = $match[1];
392
    } /*
393
  * rule: user unknown
394
  * <[email protected]>: Recipient address rejected: ...(in reply to RCPT
395
    TO command).....
@@ 396-400 (lines=5) @@
393
  * rule: user unknown
394
  * <[email protected]>: Recipient address rejected: ...(in reply to RCPT
395
    TO command).....
396
  */ elseif (preg_match("/<(\S+@\S+\w)>.*recipient address rejected/i", $body, $match)) {
397
        $result['rule_cat'] = 'unknown';
398
        $result['rule_no']  = '0308';
399
        $result['email']    = $match[1];
400
    } /*
401
  * rule: user unknown
402
  * <[email protected]>: host ... said: 550 Recipient
403
    does not exist (in reply to RCPT TO command).....
@@ 404-408 (lines=5) @@
401
  * rule: user unknown
402
  * <[email protected]>: host ... said: 550 Recipient
403
    does not exist (in reply to RCPT TO command).....
404
  */ elseif (preg_match("/<(\S+@\S+\w)>.*550 recipient.*\n?.*does not exist/i", $body, $match)) {
405
        $result['rule_cat'] = 'unknown';
406
        $result['rule_no']  = '0309';
407
        $result['email']    = $match[1];
408
    } /*
409
  * rule: user unknown
410
  * <[email protected]>: host .... said: 554 mailbox not found.....
411
  */ elseif (preg_match("/<(\S+@\S+\w)>.*554 mailbox not found/i", $body, $match)) {
@@ 411-415 (lines=5) @@
408
    } /*
409
  * rule: user unknown
410
  * <[email protected]>: host .... said: 554 mailbox not found.....
411
  */ elseif (preg_match("/<(\S+@\S+\w)>.*554 mailbox not found/i", $body, $match)) {
412
        $result['rule_cat'] = 'unknown';
413
        $result['rule_no']  = '0310';
414
        $result['email']    = $match[1];
415
    } /*
416
  * rule: too many recipients
417
  * <[email protected]>: .... said: 553 sorry, too many recipients.....
418
  */ elseif (preg_match("/<(\S+@\S+\w)>.*553 sorry, too many recipients/i", $body, $match)) {
@@ 503-507 (lines=5) @@
500
         * sample:   DSN Message only
501
         * User quota exceeded: SMTP <[email protected]>
502
         */
503
        if (preg_match("/quota exceed.*<(\S+@\S+\w)>/is", $dsn_msg, $match)) {
504
            $result['rule_cat'] = 'full';
505
            $result['rule_no']  = '0161';
506
            $result['email']    = $match[1];
507
        }
508
    } else {
509
        /* action could be one of them as RFC:1894
510
         * "failed" / "delayed" / "delivered" / "relayed" / "expanded"