Completed
Push — master ( 1efd9b...da0be0 )
by Lars
02:55
created

phpmailer-bmh_rules.php ➔ bmhDSNRules()   F

Complexity

Conditions 143
Paths > 20000

Size

Total Lines 1065
Code Lines 427

Duplication

Lines 25
Ratio 2.35 %

Code Coverage

Tests 231
CRAP Score 4226.4347

Importance

Changes 0
Metric Value
cc 143
eloc 427
nc 40960
nop 3
dl 25
loc 1065
rs 2
c 0
b 0
f 0
ccs 231
cts 556
cp 0.4155
crap 4226.4347

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 73 and the first side effect is on line 34.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*~ phpmailer-bmh_rules.php
3
.---------------------------------------------------------------------------.
4
|  Software: PHPMailer-BMH (Bounce Mail Handler)                            |
5
|   Version: 5.2-dev                                                        |
6
|   Contact: [email protected]                             |
7
|      Info: http://phpmailer.codeworxtech.com                              |
8
| ------------------------------------------------------------------------- |
9
|    Author: Andy Prevost [email protected] (admin)                 |
10
| Copyright (c) 2002-2009, Andy Prevost. All Rights Reserved.               |
11
| ------------------------------------------------------------------------- |
12
|   License: Distributed under the General Public License (GPL)             |
13
|            (http://www.gnu.org/licenses/gpl.html)                         |
14
| This program is distributed in the hope that it will be useful - WITHOUT  |
15
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     |
16
| FITNESS FOR A PARTICULAR PURPOSE.                                         |
17
| ------------------------------------------------------------------------- |
18
| This is a update of the original Bounce Mail Handler script               |
19
| http://sourceforge.net/projects/bmh/                                      |
20
| The script has been renamed from Bounce Mail Handler to PHPMailer-BMH     |
21
| ------------------------------------------------------------------------- |
22
| We offer a number of paid services:                                       |
23
| - Web Hosting on highly optimized fast and secure servers                 |
24
| - Technology Consulting                                                   |
25
| - Oursourcing (highly qualified programmers and graphic designers)        |
26
'---------------------------------------------------------------------------'
27
28
/**
29
* next rule number (BODY): 0257 <br />
30
* default category:        unrecognized: <br />
31
* default rule no.:        0000 <br />
32
*/
33
34
global $rule_categories;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
35
$rule_categories = array(
36
    'antispam'       => array('remove' => 0, 'bounce_type' => 'blocked'),
37
    'autoreply'      => array('remove' => 0, 'bounce_type' => 'autoreply'),
38
    'concurrent'     => array('remove' => 0, 'bounce_type' => 'soft'),
39
    'content_reject' => array('remove' => 0, 'bounce_type' => 'soft'),
40
    'command_reject' => array('remove' => 1, 'bounce_type' => 'hard'),
41
    'internal_error' => array('remove' => 0, 'bounce_type' => 'temporary'),
42
    'defer'          => array('remove' => 0, 'bounce_type' => 'soft'),
43
    'delayed'        => array('remove' => 0, 'bounce_type' => 'temporary'),
44
    'dns_loop'       => array('remove' => 1, 'bounce_type' => 'hard'),
45
    'dns_unknown'    => array('remove' => 1, 'bounce_type' => 'hard'),
46
    'full'           => array('remove' => 0, 'bounce_type' => 'soft'),
47
    'inactive'       => array('remove' => 1, 'bounce_type' => 'hard'),
48
    'latin_only'     => array('remove' => 0, 'bounce_type' => 'soft'),
49
    'other'          => array('remove' => 1, 'bounce_type' => 'generic'),
50
    'oversize'       => array('remove' => 0, 'bounce_type' => 'soft'),
51
    'outofoffice'    => array('remove' => 0, 'bounce_type' => 'soft'),
52
    'unknown'        => array('remove' => 1, 'bounce_type' => 'hard'),
53
    'unrecognized'   => array('remove' => 0, 'bounce_type' => false,),
54
    'user_reject'    => array('remove' => 1, 'bounce_type' => 'hard'),
55
    'warning'        => array('remove' => 0, 'bounce_type' => 'soft'),
56
);
57
58
/*
59
 * var for new line ending
60
 */
61
$bmh_newline = "<br />\n";
62
63
/**
64
 * Defined bounce parsing rules for non-standard DSN
65
 *
66
 * @param string  $body       body of the email
67
 * @param string  $structure  message structure
68
 * @param boolean $debug_mode show debug info. or not
69
 *
70
 * @return array    $result an array include the following fields: 'email', 'bounce_type','remove','rule_no','rule_cat'
71
 *                      if we could NOT detect the type of bounce, return rule_no = '0000'
72
 */
73
function bmhBodyRules($body, $structure, $debug_mode = false)
0 ignored issues
show
Unused Code introduced by
The parameter $structure is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
74
{
75
  // initialize the result array
76
  $result = array(
77 2
      'email'           => '',
78 2
      'bounce_type'     => false,
79 2
      'remove'          => 0,
80 2
      'rule_cat'        => 'unrecognized',
81 2
      'rule_no'         => '0000',
82 2
      'status_code'     => '',
83 2
      'action'          => '',
84 2
      'diagnostic_code' => '',
85 2
  );
86
87
  // ======== rules =========
88
89
  /* rule: dns_unknown
90
   * sample:
91
   *   Technical details of permanent failure:
92
   *   DNS Error: Domain name not found
93
   */
94 2
  if (preg_match("/domain\s+name\s+not\s+found/i", $body, $match)) {
95
    $result['rule_cat'] = 'dns_unknown';
96
    $result['rule_no'] = '0999';
97
  } /* rule: unknown
98
   * sample:
99
   *   [email protected]
100
   *   no such address here
101
   */
102 2 View Code Duplication
  elseif (preg_match("/no\s+such\s+address\s+here/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
103
    $result['rule_cat'] = 'unknown';
104
    $result['rule_no'] = '0237';
105
  } /* rule: unknown
106
   * sample:
107
   *   <[email protected]>:
108
   *   111.111.111.111 does not like recipient.
109
   *   Remote host said: 550 User unknown
110
   */
111 2 View Code Duplication
  elseif (preg_match("/user\s+unknown/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
112 2
    $result['rule_cat'] = 'unknown';
113 2
    $result['rule_no'] = '0236';
114 2
  } /* rule: unknown
115
   * sample:
116
   *
117
   */
118 2 View Code Duplication
  elseif (preg_match("/unknown\s+user/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
119 2
    $result['rule_cat'] = 'unknown';
120 2
    $result['rule_no'] = '0249';
121 2
  } /* rule: unknown
122
   * sample:
123
   *   <[email protected]>:
124
   *   Sorry, no mailbox here by that name. vpopmail (#5.1.1)
125
   */
126 1 View Code Duplication
  elseif (preg_match("/no\s+mailbox/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
127 1
    $result['rule_cat'] = 'unknown';
128 1
    $result['rule_no'] = '0157';
129 1
  } /* rule: unknown
130
   * sample:
131
   *   [email protected]<br>
132
   *   local: Sorry, can't find user's mailbox. (#5.1.1)<br>
133
   */
134 1 View Code Duplication
  elseif (preg_match("/can't\s+find.*mailbox/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
135
    $result['rule_cat'] = 'unknown';
136
    $result['rule_no'] = '0164';
137
  } /* rule: unknown
138
   * sample:
139
   *   ##########################################################
140
   *   #  This is an automated response from a mail delivery    #
141
   *   #  program.  Your message could not be delivered to      #
142
   *   #  the following address:                                #
143
   *   #                                                        #
144
   *   #      "|/usr/local/bin/mailfilt -u #dkms"               #
145
   *   #        (reason: Can't create output)                   #
146
   *   #        (expanded from: <[email protected]>)         #
147
   *   #                                                        #
148
   */
149 1 View Code Duplication
  elseif (preg_match("/Can't\s+create\s+output.*<(\S+@\S+\w)>/is", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
150
    $result['rule_cat'] = 'unknown';
151
    $result['rule_no'] = '0169';
152
    $result['email'] = $match[1];
153
  } /* rule: unknown
0 ignored issues
show
Unused Code Comprehensibility introduced by
61% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
154
   * sample:
155
   *   ????????????????:
156
   *   [email protected] : ????, ?????.
157
   */
158 1 View Code Duplication
  elseif (preg_match('/=D5=CA=BA=C5=B2=BB=B4=E6=D4=DA/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
159
    $result['rule_cat'] = 'unknown';
160
    $result['rule_no'] = '0174';
161
  } /* rule: unknown
162
   * sample:
163
   *   [email protected]
164
   *   Unrouteable address
165
   */
166 1 View Code Duplication
  elseif (preg_match("/Unrouteable\s+address/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
    $result['rule_cat'] = 'unknown';
168
    $result['rule_no'] = '0179';
169
  } /* rule: unknown
170
   * sample:
171
   *   Delivery to the following recipients failed.
172
   *   [email protected]
173
   */
174 1 View Code Duplication
  elseif (preg_match("/delivery[^\n\r]+failed\S*\s+(\S+@\S+\w)\s/is", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
175 1
    $result['rule_cat'] = 'unknown';
176 1
    $result['rule_no'] = '0013';
177 1
    $result['email'] = $match[1];
178 1
  } /* rule: unknown
179
   * sample:
180
   *   A message that you sent could not be delivered to one or more of its
181
   *   recipients. This is a permanent error. The following address(es) failed:
182
   *
183
   *   [email protected]
184
   *   unknown local-part "xxxxx" in domain "yourdomain.com"
185
   */
186 1 View Code Duplication
  elseif (preg_match("/unknown\s+local-part/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
187
    $result['rule_cat'] = 'unknown';
188
    $result['rule_no'] = '0232';
189
  } /* rule: unknown
190
   * sample:
191
   *   <[email protected]>:
192
   *   111.111.111.11 does not like recipient.
193
   *   Remote host said: 550 Invalid recipient: <[email protected]>
194
   */
195 1 View Code Duplication
  elseif (preg_match("/Invalid.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/is", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
196
    $result['rule_cat'] = 'unknown';
197
    $result['rule_no'] = '0233';
198
    $result['email'] = $match[1];
199
  } /* rule: unknown
200
   * sample:
201
   *   Sent >>> RCPT TO: <[email protected]>
202
   *   Received <<< 550 [email protected]... No such user
203
   *
204
   *   Could not deliver mail to this user.
205
   *   [email protected]
206
   *   *****************     End of message     ***************
207
   */
208 1 View Code Duplication
  elseif (preg_match("/No\s+such.*(?:alias|account|recipient|address|email|mailbox|user).*<(\S+@\S+\w)>/is", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
209
    $result['rule_cat'] = 'unknown';
210
    $result['rule_no'] = '0234';
211
    $result['email'] = $match[1];
212
  } /* rule: unknown
213
   * sample:
214
   *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
215
   */
216 1 View Code Duplication
  elseif (preg_match('/not unique.\s+Several matches found/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
217 1
    $result['rule_cat'] = 'unknown';
218 1
    $result['rule_no'] = '0254';
219 1
  } /* rule: full
220
   * sample 1:
221
   *   <[email protected]>:
222
   *   This account is over quota and unable to receive mail.
223
   *   sample 2:
224
   *   <[email protected]>:
225
   *   Warning: undefined mail delivery mode: normal (ignored).
226
   *   The users mailfolder is over the allowed quota (size). (#5.2.2)
227
   */
228 1 View Code Duplication
  elseif (preg_match('/over.*quota/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
229 1
    $result['rule_cat'] = 'full';
230 1
    $result['rule_no'] = '0182';
231 1
  } /* rule: full
232
   * sample:
233
   *   ----- Transcript of session follows -----
234
   *   mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
235
   *   554 <[email protected]>... Service unavailable
236
   */
237 1 View Code Duplication
  elseif (preg_match("/quota\s+exceeded.*<(\S+@\S+\w)>/is", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
238
    $result['rule_cat'] = 'full';
239
    $result['rule_no'] = '0126';
240
    $result['email'] = $match[1];
241
  } /* rule: full
242
   * sample:
243
   *   Hi. This is the qmail-send program at 263.domain.com.
244
   *   <[email protected]>:
245
   *   - User disk quota exceeded. (#4.3.0)
246
   */
247 1 View Code Duplication
  elseif (preg_match("/quota\s+exceeded/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
248
    $result['rule_cat'] = 'full';
249
    $result['rule_no'] = '0158';
250
  } /* rule: full
251
   * sample:
252
   *   [email protected]
253
   *   mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):
254
   */
255 1 View Code Duplication
  elseif (preg_match('/mailbox.*full/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
256
    $result['rule_cat'] = 'full';
257
    $result['rule_no'] = '0166';
258
  } /* rule: full
259
   * sample:
260
   *   The message to [email protected] is bounced because : Quota exceed the hard limit
261
   */
262 1 View Code Duplication
  elseif (preg_match("/The message to (\S+@\S+\w)\s.*bounce.*Quota exceed/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
263
    $result['rule_cat'] = 'full';
264
    $result['rule_no'] = '0168';
265
    $result['email'] = $match[1];
266
  } /* rule: full
267
   * sample:
268
   *   Message rejected. Not enough storage space in user's mailbox to accept message.
269
   */
270 1 View Code Duplication
  elseif (preg_match("/not\s+enough\s+storage\s+space/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
271 1
    $result['rule_cat'] = 'full';
272 1
    $result['rule_no'] = '0253';
273 1
  } /* rule: inactive
274
   * sample:
275
   *   [email protected]<br>
276
   *   553 user is inactive (eyou mta)
277
   */
278 1 View Code Duplication
  elseif (preg_match('/user is inactive/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
279
    $result['rule_cat'] = 'inactive';
280
    $result['rule_no'] = '0171';
281
  } /*
282
   * <[email protected]> is restricted
283
   */
284 1 View Code Duplication
  elseif (preg_match("/(\S+@\S+\w).*n? is restricted/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
285
    $result['rule_cat'] = 'inactive';
286
    $result['rule_no'] = '0201';
287
  } /* rule: inactive
288
   * sample:
289
   *   [email protected] [Inactive account]
290
   */
291 1 View Code Duplication
  elseif (preg_match('/inactive account/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
292
    $result['rule_cat'] = 'inactive';
293
    $result['rule_no'] = '0181';
294
  } /*
295
   *<[email protected]>: host mx3.HOTMAIL.COM said: 550
296
   * Requested action not taken: mailbox unavailable (in reply to RCPT TO command)
297
   */
298 1 View Code Duplication
  elseif (preg_match("/<(\S+@\S+\w)>.*\n.*mailbox unavailable/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
299
    $result['rule_cat'] = 'unknown';
300
    $result['rule_no'] = '124';
301
  } /*
302
   * rule: mailbox unknown;
303
   * sample:
304
   * [email protected]
305
   * 550-5.1.1 The email
306
   * account that you tried to reach does not exist. Please try 550-5.1.1
307
   * double-checking the recipient's email address for typos or 550-5.1.1
308
   * unnecessary spaces. Learn more at 550 5.1.1
309
   * http://support.google.com/mail/bin/answer.py?answer=6596 n7si4762785wiy.46
310
   * (in reply to RCPT TO command)
311
   */
312 1 View Code Duplication
  elseif (preg_match("/<(\S+@\S+\w)>.*\n?.*\n?.*account that you tried to reach does not exist/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
313
    $result['rule_cat'] = 'unknown';
314
    $result['rule_no'] = '7770';
315
    $result['email'] = $match[1];
316
  } /* rule: dns_unknown
317
   * sample1:
318
   *   Delivery to the following recipient failed permanently:
319
   *
320
   *     [email protected]
321
   *
322
   *   Technical details of permanent failure:
323
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
324
   *   [b.c (1): Connection timed out]
325
   * sample2:
326
   *   Delivery to the following recipient failed permanently:
327
   *
328
   *     [email protected]
329
   *
330
   *   Technical details of permanent failure:
331
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
332
   *   [pop.b.c (1): Connection dropped]
333
   */
334 1 View Code Duplication
  elseif (preg_match('/Technical details of permanent failure:\s+TEMP_FAILURE: Could not initiate SMTP conversation with any hosts/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
335 1
    $result['rule_cat'] = 'dns_unknown';
336 1
    $result['rule_no'] = '0251';
337 1
  } /* rule: delayed
338
   * sample:
339
   *   Delivery to the following recipient has been delayed:
340
   *
341
   *     [email protected]
342
   *
343
   *   Message will be retried for 2 more day(s)
344
   *
345
   *   Technical details of temporary failure:
346
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
347
   *   [b.c (50): Connection timed out]
348
   */
349 1 View Code Duplication
  elseif (preg_match('/Technical details of temporary failure:\s+TEMP_FAILURE: Could not initiate SMTP conversation with any hosts/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
350 1
    $result['rule_cat'] = 'delayed';
351 1
    $result['rule_no'] = '0252';
352 1
  } /* rule: delayed
353
   * sample:
354
   *   Delivery to the following recipient has been delayed:
355
   *
356
   *     [email protected]
357
   *
358
   *   Message will be retried for 2 more day(s)
359
   *
360
   *   Technical details of temporary failure:
361
   *   TEMP_FAILURE: The recipient server did not accept our requests to connect. Learn more at ...
362
   *   [b.c (10): Connection dropped]
363
   */
364 1 View Code Duplication
  elseif (preg_match('/Technical details of temporary failure:\s+TEMP_FAILURE: The recipient server did not accept our requests to connect./i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
365 1
    $result['rule_cat'] = 'delayed';
366 1
    $result['rule_no'] = '0256';
367 1
  } /* rule: internal_error
368
   * sample:
369
   *   <[email protected]>:
370
   *   Unable to switch to /var/vpopmail/domains/domain.com: input/output error. (#4.3.0)
371
   */
372 1 View Code Duplication
  elseif (preg_match("/input\/output error/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
373
    $result['rule_cat'] = 'internal_error';
374
    $result['rule_no'] = '0172';
375
    $result['bounce_type'] = 'hard';
376
    $result['remove'] = 1;
377
  } /* rule: internal_error
378
   * sample:
379
   *   <[email protected]>:
380
   *   can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350
381
   */
382 1 View Code Duplication
  elseif (preg_match('/can not open new email file/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
383
    $result['rule_cat'] = 'internal_error';
384
    $result['rule_no'] = '0173';
385
    $result['bounce_type'] = 'hard';
386
    $result['remove'] = 1;
387
  } /* rule: defer
388
   * sample:
389
   *   <[email protected]>:
390
   *   111.111.111.111 failed after I sent the message.
391
   *   Remote host said: 451 mta283.mail.scd.yahoo.com Resources temporarily unavailable. Please try again later [#4.16.5].
392
   */
393 1 View Code Duplication
  elseif (preg_match('/Resources temporarily unavailable/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
394
    $result['rule_cat'] = 'defer';
395
    $result['rule_no'] = '0163';
396
  } /* rule: autoreply
397
   * sample:
398
   *   AutoReply message from [email protected]
399
   */
400 1 View Code Duplication
  elseif (preg_match("/^AutoReply message from (\S+@\S+\w)/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
401
    $result['rule_cat'] = 'autoreply';
402
    $result['rule_no'] = '0167';
403
    $result['email'] = $match[1];
404
  } /* rule: block
405
   * sample:
406
   *   Delivery to the following recipient failed permanently:
407
   *     [email protected]
408
   *   Technical details of permanent failure:
409
   *   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.
410
   */
411 1 View Code Duplication
  elseif (preg_match("/Your message \([^)]+\) was blocked by/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
412 1
    $result['rule_cat'] = 'antispam';
413 1
    $result['rule_no'] = '0250';
414 1
  } /* rule: content_reject
415
   * sample:
416
   *   Failed to deliver to '<[email protected]>'
417
   *   Messages without To: fields are not accepted here
418
   */
419 1 View Code Duplication
  elseif (preg_match("/Messages\s+without\s+\S+\s+fields\s+are\s+not\s+accepted\s+here/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
420 1
    $result['rule_cat'] = 'content_reject';
421 1
    $result['rule_no'] = '0248';
422 1
  }  /* rule: inactive
423
   * sample:
424
   *   <[email protected]>:
425
   *   This address no longer accepts mail.
426
   */
427 1 View Code Duplication
  elseif (preg_match("/(?:alias|account|recipient|address|email|mailbox|user).*no\s+longer\s+accepts\s+mail/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
428
    $result['rule_cat'] = 'inactive';
429
    $result['rule_no'] = '0235';
430
  } /* rule: western chars only
431
   * sample:
432
   *   <[email protected]>:
433
   *   The user does not accept email in non-Western (non-Latin) character sets.
434
   */
435 1 View Code Duplication
  elseif (preg_match("/does not accept[^\r\n]*non-Western/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
436
    $result['rule_cat'] = 'latin_only';
437
    $result['rule_no'] = '0043';
438
  } /* rule: unknown
439
   * sample:
440
   *   554 delivery error
441
   *   This user doesn't have a yahoo.com account
442
   */
443 1 View Code Duplication
  elseif (preg_match("/554.*delivery error.*this user.*doesn't have.*account/is", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
444
    $result['rule_cat'] = 'unknown';
445
    $result['rule_no'] = '0044';
446
  } /* rule: unknown
447
   * sample:
448
   *   550 hotmail.com
449
   */
450 1 View Code Duplication
  elseif (preg_match('/550.*Requested.*action.*not.*taken:.*mailbox.*unavailable/is', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
451
    $result['rule_cat'] = 'unknown';
452
    $result['rule_no'] = '0045';
453
  } /* rule: unknown
454
   * sample:
455
   *   550 5.1.1 aim.com
456
   */
457 1 View Code Duplication
  elseif (preg_match("/550 5\.1\.1.*Recipient address rejected/is", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
458
    $result['rule_cat'] = 'unknown';
459
    $result['rule_no'] = '0046';
460
  } /* rule: unknown
461
   * sample:
462
   *   550 .* (in reply to end of DATA command)
463
   */
464 1 View Code Duplication
  elseif (preg_match('/550.*in reply to end of DATA command/i', $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
465
    $result['rule_cat'] = 'unknown';
466
    $result['rule_no'] = '0047';
467
  } /* rule: unknown
468
   * sample:
469
   *   550 .* (in reply to RCPT TO command)
470
   */
471 1
  elseif (preg_match('/550.*in reply to RCPT TO command/i', $body, $match)) {
472
    $result['rule_cat'] = 'unknown';
473
    $result['rule_no'] = '0048';
474
  } /* rule: dns_unknown
475
   * sample:
476
   *    [email protected]:
477
   *      unrouteable mail domain "b.c"
478
   */
479 1 View Code Duplication
  elseif (preg_match("/unrouteable\s+mail\s+domain/i", $body, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
480 1
    $result['rule_cat'] = 'dns_unknown';
481 1
    $result['rule_no'] = '0247';
482 1
  }
483
484 2
  if ($result['rule_no'] !== '0000' && $result['email'] === '') {
485 2
    $preBody = substr($body, 0, strpos($body, $match[0]));
486
487 2
    $count = preg_match_all('/(\S+@\S+)/', $preBody, $match);
488 2
    if ($count) {
489 2
      $result['email'] = trim($match[1][$count - 1], "'\"()<>.:; \t\r\n\0\x0B");
490 2
    }
491 2
  }
492
493 2
  global $rule_categories, $bmh_newline;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
494 2
  if ($result['rule_no'] == '0000') {
495 1
    if ($debug_mode) {
496
      echo 'Body:' . $bmh_newline . $body . $bmh_newline;
497
      echo $bmh_newline;
498
    }
499 1 View Code Duplication
  } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
500 2
    if ($result['bounce_type'] === false) {
501 2
      $result['bounce_type'] = $rule_categories[$result['rule_cat']]['bounce_type'];
502 2
      $result['remove'] = $rule_categories[$result['rule_cat']]['remove'];
503 2
    }
504
  }
505
506 2
  return $result;
507
}
508
509
/**
510
 * Defined bounce parsing rules for standard DSN (Delivery Status Notification)
511
 *
512
 * @param string  $dsn_msg    human-readable explanation
513
 * @param string  $dsn_report delivery-status report
514
 * @param boolean $debug_mode show debug info. or not
515
 *
516
 * @return array    $result an array include the following fields: 'email', 'bounce_type','remove','rule_no','rule_cat'
517
 *                      if we could NOT detect the type of bounce, return rule_no = '0000'
518
 */
519
function bmhDSNRules($dsn_msg, $dsn_report, $debug_mode = false)
520
{
521
  // initialize the result array
522
  $result = array(
523 2
      'email'           => '',
524 2
      'bounce_type'     => false,
525 2
      'remove'          => 0,
526 2
      'rule_cat'        => 'unrecognized',
527 2
      'rule_no'         => '0000',
528 2
      'status_code'     => '',
529 2
      'action'          => '',
530 2
      'diagnostic_code' => '',
531 2
  );
532 2
  $action = false;
533 2
  $status_code = false;
534 2
  $diag_code = false;
535
536
  // ======= parse $dsn_report ======
537
  // get the recipient email
538 2
  if (preg_match('/Original-Recipient: rfc822;(.*)/i', $dsn_report, $match)) {
539 1
    $email = trim($match[1], "<> \t\r\n\0\x0B");
540
    /** @noinspection PhpUsageOfSilenceOperatorInspection */
541 1
    $email_arr = @imap_rfc822_parse_adrlist($email, 'default.domain.name');
542 1 View Code Duplication
    if (isset($email_arr[0]->host) && $email_arr[0]->host != '.SYNTAX-ERROR.' && $email_arr[0]->host != 'default.domain.name') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
543 1
      $result['email'] = $email_arr[0]->mailbox . '@' . $email_arr[0]->host;
544 1
    }
545 2
  } elseif (preg_match('/Final-Recipient: rfc822;(.*)/i', $dsn_report, $match)) {
546 2
    $email = trim($match[1], "<> \t\r\n\0\x0B");
547
    /** @noinspection PhpUsageOfSilenceOperatorInspection */
548 2
    $email_arr = @imap_rfc822_parse_adrlist($email, 'default.domain.name');
549 2 View Code Duplication
    if (isset($email_arr[0]->host) && $email_arr[0]->host != '.SYNTAX-ERROR.' && $email_arr[0]->host != 'default.domain.name') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
550 2
      $result['email'] = $email_arr[0]->mailbox . '@' . $email_arr[0]->host;
551 2
    }
552 2
  }
553
554 2 View Code Duplication
  if (preg_match('/Action: (.+)/i', $dsn_report, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
555 2
    $action = strtolower(trim($match[1]));
556 2
    $result['action'] = $action;
557 2
  }
558
559 2 View Code Duplication
  if (preg_match("/Status: ([0-9\.]+)/i", $dsn_report, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
560 2
    $status_code = $match[1];
561 2
    $result['status_code'] = $status_code;
562 2
  }
563
564
  // Could be multi-line , if the new line is beginning with SPACE or HTAB
565 2
  if (preg_match("/Diagnostic-Code:((?:[^\n]|\n[\t ])+)(?:\n[^\t ]|$)/is", $dsn_report, $match)) {
566 2
    $diag_code = $match[1];
567 2
  }
568
569
  // No Diagnostic-Code in email, use dsn message
570 2
  if (empty($diag_code)) {
571 2
    $diag_code = $dsn_msg;
572 2
  }
573
574 2
  $result['diagnostic_code'] = $diag_code;
575
576
  // ======= rules ======
577
578 2
  if (empty($result['email'])) {
579
    /* email address is empty
580
     * rule: full
581
     * sample:   DSN Message only
582
     * User quota exceeded: SMTP <[email protected]>
583
     */
584 1 View Code Duplication
    if (preg_match("/quota exceed.*<(\S+@\S+\w)>/is", $dsn_msg, $match)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
585
      $result['rule_cat'] = 'full';
586
      $result['rule_no'] = '0161';
587
      $result['email'] = $match[1];
588
    }
589 1
  } else {
590
    /* action could be one of them as RFC:1894
591
     * "failed" / "delayed" / "delivered" / "relayed" / "expanded"
592
     */
593
    switch ($action) {
594 2
      case 'failed':
595
        /* rule: full
596
         * sample:
597
         *   Diagnostic-Code: X-Postfix; me.domain.com platform: said: 552 5.2.2 Over
598
         *     quota (in reply to RCPT TO command)
599
         */
600 2
        if (preg_match('/over.*quota/is', $diag_code)) {
601 1
          $result['rule_cat'] = 'full';
602 1
          $result['rule_no'] = '0105';
603 1
        } /* rule: full
604
         * sample:
605
         *   Diagnostic-Code: SMTP; 552 Requested mailbox exceeds quota.
606
         */
607 2
        elseif (preg_match('/exceed.*quota/is', $diag_code)) {
608
          $result['rule_cat'] = 'full';
609
          $result['rule_no'] = '0129';
610
        } /* rule: full
611
         * sample 1:
612
         *   Diagnostic-Code: smtp;552 5.2.2 This message is larger than the current system limit or the recipient's mailbox is full. Create a shorter message body or remove attachments and try sending it again.
613
         * sample 2:
614
         *   Diagnostic-Code: X-Postfix; host mta5.us4.domain.com.int[111.111.111.111] said:
615
         *     552 recipient storage full, try again later (in reply to RCPT TO command)
616
         * sample 3:
617
         *   Diagnostic-Code: X-HERMES; host 127.0.0.1[127.0.0.1] said: 551 bounce as<the
618
         *     destination mailbox <[email protected]> is full> queue as
619
         *     [email protected] (in reply to end of
620
         *     DATA command)
621
         */
622 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*full/is', $diag_code)) {
623 1
          $result['rule_cat'] = 'full';
624 1
          $result['rule_no'] = '0145';
625 1
        } /* rule: full
626
         * sample:
627
         *   Diagnostic-Code: SMTP; 452 Insufficient system storage
628
         */
629 2
        elseif (preg_match('/Insufficient system storage/is', $diag_code)) {
630
          $result['rule_cat'] = 'full';
631
          $result['rule_no'] = '0134';
632
        } /* rule: full
633
         * sample:
634
         *   Diagnostic-Code: SMTP; 422 Benutzer hat zuviele Mails auf dem Server
635
         */
636 2
        elseif (preg_match('/Benutzer hat zuviele Mails auf dem Server/is', $diag_code)) {
637
          $result['rule_cat'] = 'full';
638
          $result['rule_no'] = '0998';
639
        } /* rule: full
640
         * sample:
641
         *   Diagnostic-Code: SMTP; 422 exceeded storage allocation
642
         */
643 2
        elseif (preg_match('/exceeded storage allocation/is', $diag_code)) {
644
          $result['rule_cat'] = 'full';
645
          $result['rule_no'] = '0997';
646
        } /* rule: full
647
         * sample:
648
         *   Diagnostic-Code: SMTP; 422 Mailbox quota usage exceeded
649
         */
650 2
        elseif (preg_match('/Mailbox quota usage exceeded/is', $diag_code)) {
651
          $result['rule_cat'] = 'full';
652
          $result['rule_no'] = '0996';
653
        } /* rule: full
654
         * sample:
655
         *   Diagnostic-Code: SMTP; 422 User has exhausted allowed storage space
656
         */
657 2
        elseif (preg_match('/User has exhausted allowed storage space/is', $diag_code)) {
658
          $result['rule_cat'] = 'full';
659
          $result['rule_no'] = '0995';
660
        } /* rule: full
661
         * sample:
662
         *   Diagnostic-Code: SMTP; 422 User mailbox exceeds allowed size
663
         */
664 2
        elseif (preg_match('/User mailbox exceeds allowed size/is', $diag_code)) {
665
          $result['rule_cat'] = 'full';
666
          $result['rule_no'] = '0994';
667
        } /* rule: full
668
         * sample:
669
         *   Diagnostic-Code: smpt; 552 Account(s) <[email protected]> does not have enough space
670
         */
671 2
        elseif (preg_match("/not.*enough\s+space/i", $diag_code)) {
672 1
          $result['rule_cat'] = 'full';
673 1
          $result['rule_no'] = '0246';
674 1
        } /* rule: full
675
         * sample 1:
676
         *   Diagnostic-Code: X-Postfix; cannot append message to destination file
677
         *     /var/mail/dale.me89g: error writing message: File too large
678
         * sample 2:
679
         *   Diagnostic-Code: X-Postfix; cannot access mailbox /var/spool/mail/b8843022 for
680
         *     user xxxxx. error writing message: File too large
681
         */
682 2
        elseif (preg_match('/File too large/is', $diag_code)) {
683
          $result['rule_cat'] = 'full';
684
          $result['rule_no'] = '0192';
685
        } /* rule: oversize
686
         * sample:
687
         *   Diagnostic-Code: smtp;552 5.2.2 This message is larger than the current system limit or the recipient's mailbox is full. Create a shorter message body or remove attachments and try sending it again.
688
         */
689 2
        elseif (preg_match('/larger than.*limit/is', $diag_code)) {
690
          $result['rule_cat'] = 'oversize';
691
          $result['rule_no'] = '0146';
692
        } /* rule: unknown
693
         * sample:
694
         *   Diagnostic-Code: X-Notes; User xxxxx ([email protected]) not listed in public Name & Address Book
695
         */
696 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user)(.*)not(.*)list/is', $diag_code)) {
697 1
          $result['rule_cat'] = 'unknown';
698 1
          $result['rule_no'] = '0103';
699 1
        } /* rule: unknown
700
         * sample:
701
         *   Diagnostic-Code: smtp; 450 user path no exist
702
         */
703 2
        elseif (preg_match('/user path no exist/is', $diag_code)) {
704
          $result['rule_cat'] = 'unknown';
705
          $result['rule_no'] = '0106';
706
        } /* rule: unknown
707
         * sample 1:
708
         *   Diagnostic-Code: SMTP; 550 Relaying denied.
709
         * sample 2:
710
         *   Diagnostic-Code: SMTP; 554 <[email protected]>: Relay access denied
711
         * sample 3:
712
         *   Diagnostic-Code: SMTP; 550 relaying to <[email protected]> prohibited by administrator
713
         */
714 2
        elseif (preg_match('/Relay.*(?:denied|prohibited)/is', $diag_code)) {
715 1
          $result['rule_cat'] = 'unknown';
716 1
          $result['rule_no'] = '0108';
717 1
        } /* rule: unknown
718
         * sample:
719
         *   Diagnostic-Code: SMTP; 554 qq Sorry, no valid recipients (#5.1.3)
720
         */
721 2
        elseif (preg_match('/no.*valid.*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
722
          $result['rule_cat'] = 'unknown';
723
          $result['rule_no'] = '0185';
724
        } /* rule: unknown
725
         * sample 1:
726
         *   Diagnostic-Code: SMTP; 550 «Dªk¦a§} - invalid address (#5.5.0)
727
         * sample 2:
728
         *   Diagnostic-Code: SMTP; 550 Invalid recipient: <[email protected]>
729
         * sample 3:
730
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: Invalid User
731
         */
732 2
        elseif (preg_match('/Invalid.*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
733 1
          $result['rule_cat'] = 'unknown';
734 1
          $result['rule_no'] = '0111';
735 1
        } /* rule: unknown
736
         * sample:
737
         *   Diagnostic-Code: SMTP; 554 delivery error: dd Sorry your message to [email protected] cannot be delivered. This account has been disabled or discontinued [#102]. - mta173.mail.tpe.domain.com
738
         */
739 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*(?:disabled|discontinued)/is', $diag_code)) {
740 1
          $result['rule_cat'] = 'unknown';
741 1
          $result['rule_no'] = '0114';
742 1
        } /* rule: unknown
743
         * sample:
744
         *   Diagnostic-Code: SMTP; 554 delivery error: dd This user doesn't have a domain.com account ([email protected]) [0] - mta134.mail.tpe.domain.com
745
         */
746 2
        elseif (preg_match("/user doesn't have.*account/is", $diag_code)) {
747 2
          $result['rule_cat'] = 'unknown';
748 2
          $result['rule_no'] = '0127';
749 2
        } /* rule: unknown
750
         * sample:
751
         *   Diagnostic-Code: SMTP; 550 5.1.1 unknown or illegal alias: [email protected]
752
         */
753 2
        elseif (preg_match('/(?:unknown|illegal).*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
754 2
          $result['rule_cat'] = 'unknown';
755 2
          $result['rule_no'] = '0128';
756 2
        } /* rule: unknown
757
         * sample 1:
758
         *   Diagnostic-Code: SMTP; 450 mailbox unavailable.
759
         * sample 2:
760
         *   Diagnostic-Code: SMTP; 550 5.7.1 Requested action not taken: mailbox not available
761
         */
762 2
        elseif (preg_match("/(?:alias|account|recipient|address|email|mailbox|user).*(?:un|not\s+)available/is", $diag_code)) {
763 1
          $result['rule_cat'] = 'unknown';
764 1
          $result['rule_no'] = '0122';
765 1
        } /* rule: unknown
766
         * sample:
767
         *   Diagnostic-Code: SMTP; 553 sorry, no mailbox here by that name (#5.7.1)
768
         */
769 2
        elseif (preg_match('/no (?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
770 1
          $result['rule_cat'] = 'unknown';
771 1
          $result['rule_no'] = '0123';
772 1
        } /* rule: unknown
773
         * sample 1:
774
         *   Diagnostic-Code: SMTP; 550 User ([email protected]) unknown.
775
         * sample 2:
776
         *   Diagnostic-Code: SMTP; 553 5.3.0 <[email protected]>... Addressee unknown, relay=[111.111.111.000]
777
         */
778 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*unknown/is', $diag_code)) {
779 1
          $result['rule_cat'] = 'unknown';
780 1
          $result['rule_no'] = '0125';
781 1
        } /* rule: unknown
782
         * sample 1:
783
         *   Diagnostic-Code: SMTP; 550 user disabled
784
         * sample 2:
785
         *   Diagnostic-Code: SMTP; 452 4.2.1 mailbox temporarily disabled: [email protected]
786
         */
787 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*disabled/is', $diag_code)) {
788
          $result['rule_cat'] = 'unknown';
789
          $result['rule_no'] = '0133';
790
        } /* rule: unknown
791
         * sample:
792
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: Recipient address rejected: No such user ([email protected])
793
         */
794 2
        elseif (preg_match('/No such (?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
795
          $result['rule_cat'] = 'unknown';
796
          $result['rule_no'] = '0143';
797
        } /* rule: unknown
798
         * sample 1:
799
         *   Diagnostic-Code: SMTP; 550 MAILBOX NOT FOUND
800
         * sample 2:
801
         *   Diagnostic-Code: SMTP; 550 Mailbox ( [email protected] ) not found or inactivated
802
         */
803 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*NOT FOUND/is', $diag_code)) {
804
          $result['rule_cat'] = 'unknown';
805
          $result['rule_no'] = '0136';
806
        } /* rule: unknown
807
         * sample:
808
         *    Diagnostic-Code: X-Postfix; host m2w-in1.domain.com[111.111.111.000] said: 551
809
         *    <[email protected]> is a deactivated mailbox (in reply to RCPT TO
810
         *    command)
811
         */
812 2
        elseif (preg_match('/deactivated (?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
813
          $result['rule_cat'] = 'unknown';
814
          $result['rule_no'] = '0138';
815
        } /* rule: unknown
816
         * sample:
817
         *   Diagnostic-Code: SMTP; 550 <[email protected]> recipient rejected
818
         *   ...
819
         *   <<< 550 <[email protected]> recipient rejected
820
         *   550 5.1.1 [email protected]... User unknown
821
         */
822 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*reject/is', $diag_code)) {
823 2
          $result['rule_cat'] = 'unknown';
824 2
          $result['rule_no'] = '0148';
825 2
        } /* rule: unknown
826
         * sample:
827
         *   Diagnostic-Code: smtp; 5.x.0 - Message bounced by administrator  (delivery attempts: 0)
828
         */
829 2
        elseif (preg_match('/bounce.*administrator/is', $diag_code)) {
830
          $result['rule_cat'] = 'unknown';
831
          $result['rule_no'] = '0151';
832
        } /* rule: unknown
833
         * sample:
834
         *   Diagnostic-Code: SMTP; 550 <maxqin> is now disabled with MTA service.
835
         */
836 2
        elseif (preg_match('/<.*>.*disabled/is', $diag_code)) {
837
          $result['rule_cat'] = 'unknown';
838
          $result['rule_no'] = '0152';
839
        } /* rule: unknown
840
         * sample:
841
         *   Diagnostic-Code: SMTP; 551 not our customer
842
         */
843 2
        elseif (preg_match('/not our customer/is', $diag_code)) {
844
          $result['rule_cat'] = 'unknown';
845
          $result['rule_no'] = '0154';
846
        } /* rule: unknown
847
         * sample:
848
         *   Diagnostic-Code: smtp; 5.1.0 - Unknown address error 540-'Error: Wrong recipients' (delivery attempts: 0)
849
         */
850 2
        elseif (preg_match('/Wrong (?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
851
          $result['rule_cat'] = 'unknown';
852
          $result['rule_no'] = '0159';
853
        } /* rule: unknown
854
         * sample:
855
         *   Diagnostic-Code: smtp; 5.1.0 - Unknown address error 540-'Error: Wrong recipients' (delivery attempts: 0)
856
         * sample 2:
857
         *   Diagnostic-Code: SMTP; 501 #5.1.1 bad address [email protected]
858
         */
859 2
        elseif (preg_match('/(?:unknown|bad).*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
860
          $result['rule_cat'] = 'unknown';
861
          $result['rule_no'] = '0160';
862
        } /* rule: unknown
863
         * sample:
864
         *   Status: 5.1.1 (bad destination mailbox address)
865
         */
866 2
        elseif (preg_match('/(?:unknown|bad).*(?:alias|account|recipient|address|email|mailbox|user)/is', $status_code)) {
867
          $result['rule_cat'] = 'unknown';
868
          $result['rule_no'] = '01601';
869
        } /* rule: unknown
870
         * sample:
871
         *   Diagnostic-Code: SMTP; 550 Command RCPT User <[email protected]> not OK
872
         */
873 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*not OK/is', $diag_code)) {
874
          $result['rule_cat'] = 'unknown';
875
          $result['rule_no'] = '0186';
876
        } /* rule: unknown
877
         * sample:
878
         *   Diagnostic-Code: SMTP; 550 5.7.1 Access-Denied-XM.SSR-001
879
         */
880 2
        elseif (preg_match('/Access.*Denied/is', $diag_code)) {
881
          $result['rule_cat'] = 'unknown';
882
          $result['rule_no'] = '0189';
883
        } /* rule: unknown
884
         * sample:
885
         *   Diagnostic-Code: SMTP; 550 5.1.1 <[email protected]>... email address lookup in domain map failed
886
         */
887 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*lookup.*fail/is', $diag_code)) {
888
          $result['rule_cat'] = 'unknown';
889
          $result['rule_no'] = '0195';
890
        } /* rule: unknown
891
         * sample:
892
         *   Diagnostic-Code: SMTP; 550 User not a member of domain: <[email protected]>
893
         */
894 2
        elseif (preg_match('/(?:recipient|address|email|mailbox|user).*not.*member of domain/is', $diag_code)) {
895
          $result['rule_cat'] = 'unknown';
896
          $result['rule_no'] = '0198';
897
        } /* rule: unknown
898
         * sample:
899
         *   Diagnostic-Code: SMTP; 550-"The recipient cannot be verified.  Please check all recipients of this
900
         */
901 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*cannot be verified/is', $diag_code)) {
902
          $result['rule_cat'] = 'unknown';
903
          $result['rule_no'] = '0202';
904
        } /* rule: unknown
905
         * sample:
906
         *   Diagnostic-Code: SMTP; 550 Unable to relay for [email protected]
907
         */
908 2
        elseif (preg_match('/Unable to relay/is', $diag_code)) {
909
          $result['rule_cat'] = 'unknown';
910
          $result['rule_no'] = '0203';
911
        } /* rule: unknown
912
         * sample 1:
913
         *   Diagnostic-Code: SMTP; 550 [email protected]:user not exist
914
         * sample 2:
915
         *   Diagnostic-Code: SMTP; 550 sorry, that recipient doesn't exist (#5.7.1)
916
         */
917 2
        elseif (preg_match("/(?:alias|account|recipient|address|email|mailbox|user).*(?:n't|not) exist/is", $diag_code)) {
918 2
          $result['rule_cat'] = 'unknown';
919 2
          $result['rule_no'] = '0205';
920 2
        } /* rule: unknown
921
         * sample:
922
         *   Diagnostic-Code: SMTP; 550-I'm sorry but [email protected] does not have an account here. I will not
923
         */
924 2
        elseif (preg_match('/not have an account/is', $diag_code)) {
925
          $result['rule_cat'] = 'unknown';
926
          $result['rule_no'] = '0207';
927
        } /* rule: unknown
928
         * sample:
929
         *   Diagnostic-Code: SMTP; 550 This account is not [email protected]
930
         */
931 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*is not allowed/is', $diag_code)) {
932
          $result['rule_cat'] = 'unknown';
933
          $result['rule_no'] = '0220';
934
        } /* rule: unknown
935
         * sample:
936
         *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
937
         */
938 2
        elseif (preg_match('/not unique.\s+Several matches found/i', $diag_code)) {
939
          $result['rule_cat'] = 'unknown';
940
          $result['rule_no'] = '0255';
941
        } /* rule: inactive
942
         * sample:
943
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: inactive user
944
         */
945 2
        elseif (preg_match('/inactive.*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
946
          $result['rule_cat'] = 'inactive';
947
          $result['rule_no'] = '0135';
948
        } /* rule: inactive
949
         * sample:
950
         *   Diagnostic-Code: SMTP; 550 [email protected] Account Inactive
951
         */
952 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*Inactive/is', $diag_code)) {
953
          $result['rule_cat'] = 'inactive';
954
          $result['rule_no'] = '0155';
955
        } /* rule: inactive
956
         * sample:
957
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: Recipient address rejected: Account closed due to inactivity. No forwarding information is available.
958
         */
959 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user) closed due to inactivity/is', $diag_code)) {
960
          $result['rule_cat'] = 'inactive';
961
          $result['rule_no'] = '0170';
962
        } /* rule: inactive
963
         * sample:
964
         *   Diagnostic-Code: SMTP; 550 <[email protected]>... User account not activated
965
         */
966 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user) not activated/is', $diag_code)) {
967
          $result['rule_cat'] = 'inactive';
968
          $result['rule_no'] = '0177';
969
        } /* rule: inactive
970
         * sample 1:
971
         *   Diagnostic-Code: SMTP; 550 User suspended
972
         * sample 2:
973
         *   Diagnostic-Code: SMTP; 550 account expired
974
         */
975 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*(?:suspend|expire)/is', $diag_code)) {
976
          $result['rule_cat'] = 'inactive';
977
          $result['rule_no'] = '0183';
978
        } /* rule: inactive
979
         * sample:
980
         *   Diagnostic-Code: SMTP; 553 5.3.0 <[email protected]>... Recipient address no longer exists
981
         */
982 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*no longer exist/is', $diag_code)) {
983
          $result['rule_cat'] = 'inactive';
984
          $result['rule_no'] = '0184';
985
        } /* rule: inactive
986
         * sample:
987
         *   Diagnostic-Code: SMTP; 553 VS10-RT Possible forgery or deactivated due to abuse (#5.1.1) 111.111.111.211
988
         */
989 2
        elseif (preg_match('/(?:forgery|abuse)/is', $diag_code)) {
990
          $result['rule_cat'] = 'inactive';
991
          $result['rule_no'] = '0196';
992
        } /* rule: inactive
993
         * sample:
994
         *   Diagnostic-Code: SMTP; 553 mailbox [email protected] is restricted
995
         */
996 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*restrict/is', $diag_code)) {
997
          $result['rule_cat'] = 'inactive';
998
          $result['rule_no'] = '0209';
999
        } /* rule: inactive
1000
         * sample:
1001
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: User status is locked.
1002
         */
1003 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*locked/is', $diag_code)) {
1004
          $result['rule_cat'] = 'inactive';
1005
          $result['rule_no'] = '0228';
1006
        } /* rule: user_reject
1007
         * sample:
1008
         *   Diagnostic-Code: SMTP; 553 User refused to receive this mail.
1009
         */
1010 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user) refused/is', $diag_code)) {
1011
          $result['rule_cat'] = 'user_reject';
1012
          $result['rule_no'] = '0156';
1013
        } /* rule: user_reject
1014
         * sample:
1015
         *   Diagnostic-Code: SMTP; 501 [email protected] Sender email is not in my domain
1016
         */
1017 2
        elseif (preg_match('/sender.*not/is', $diag_code)) {
1018
          $result['rule_cat'] = 'user_reject';
1019
          $result['rule_no'] = '0206';
1020
        } /* rule: command_reject
1021
         * sample:
1022
         *   Diagnostic-Code: SMTP; 554 Message refused
1023
         */
1024 2
        elseif (preg_match('/Message refused/is', $diag_code)) {
1025
          $result['rule_cat'] = 'command_reject';
1026
          $result['rule_no'] = '0175';
1027
        } /* rule: command_reject
1028
         * sample:
1029
         *   Diagnostic-Code: SMTP; 550 5.0.0 <[email protected]>... No permit
1030
         */
1031 2
        elseif (preg_match('/No permit/is', $diag_code)) {
1032
          $result['rule_cat'] = 'command_reject';
1033
          $result['rule_no'] = '0190';
1034
        } /* rule: command_reject
1035
         * sample:
1036
         *   Diagnostic-Code: SMTP; 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.5.3 - chkuser)
1037
         */
1038 2
        elseif (preg_match("/domain isn't in.*allowed rcpthost/is", $diag_code)) {
1039
          $result['rule_cat'] = 'command_reject';
1040
          $result['rule_no'] = '0191';
1041
        } /* rule: command_reject
1042
         * sample:
1043
         *   Diagnostic-Code: SMTP; 553 AUTH FAILED - [email protected]
1044
         */
1045 2
        elseif (preg_match('/AUTH FAILED/is', $diag_code)) {
1046
          $result['rule_cat'] = 'command_reject';
1047
          $result['rule_no'] = '0197';
1048
        } /* rule: command_reject
1049
         * sample 1:
1050
         *   Diagnostic-Code: SMTP; 550 relay not permitted
1051
         * sample 2:
1052
         *   Diagnostic-Code: SMTP; 530 5.7.1 Relaying not allowed: [email protected]
1053
         */
1054 2
        elseif (preg_match('/relay.*not.*(?:permit|allow)/is', $diag_code)) {
1055
          $result['rule_cat'] = 'command_reject';
1056
          $result['rule_no'] = '0241';
1057
        } /* rule: command_reject
1058
         * sample:
1059
         *   Diagnostic-Code: SMTP; 550 not local host domain.com, not a gateway
1060
         */
1061 2
        elseif (preg_match('/not local host/is', $diag_code)) {
1062
          $result['rule_cat'] = 'command_reject';
1063
          $result['rule_no'] = '0204';
1064
        } /* rule: command_reject
1065
         * sample:
1066
         *   Diagnostic-Code: SMTP; 500 Unauthorized relay msg rejected
1067
         */
1068 2
        elseif (preg_match('/Unauthorized relay/is', $diag_code)) {
1069
          $result['rule_cat'] = 'command_reject';
1070
          $result['rule_no'] = '0215';
1071
        } /* rule: command_reject
1072
         * sample:
1073
         *   Diagnostic-Code: SMTP; 554 Transaction failed
1074
         */
1075 2
        elseif (preg_match('/Transaction.*fail/is', $diag_code)) {
1076
          $result['rule_cat'] = 'command_reject';
1077
          $result['rule_no'] = '0221';
1078
        } /* rule: command_reject
1079
         * sample:
1080
         *   Diagnostic-Code: smtp;554 5.5.2 Invalid data in message
1081
         */
1082 2
        elseif (preg_match('/Invalid data/is', $diag_code)) {
1083
          $result['rule_cat'] = 'command_reject';
1084
          $result['rule_no'] = '0223';
1085
        } /* rule: command_reject
1086
         * sample:
1087
         *   Diagnostic-Code: SMTP; 550 Local user only or Authentication mechanism
1088
         */
1089 2
        elseif (preg_match('/Local user only/is', $diag_code)) {
1090
          $result['rule_cat'] = 'command_reject';
1091
          $result['rule_no'] = '0224';
1092
        } /* rule: command_reject
1093
         * sample:
1094
         *   Diagnostic-Code: SMTP; 550-ds176.domain.com [111.111.111.211] is currently not permitted to
1095
         *   relay through this server. Perhaps you have not logged into the pop/imap
1096
         *   server in the last 30 minutes or do not have SMTP Authentication turned on
1097
         *   in your email client.
1098
         */
1099 2
        elseif (preg_match('/not.*permit.*to/is', $diag_code)) {
1100
          $result['rule_cat'] = 'command_reject';
1101
          $result['rule_no'] = '0225';
1102
        } /* rule: content_reject
1103
         * sample:
1104
         *   Diagnostic-Code: SMTP; 550 Content reject. FAAAANsG60M9BmDT.1
1105
         */
1106 2
        elseif (preg_match('/Content reject/is', $diag_code)) {
1107
          $result['rule_cat'] = 'content_reject';
1108
          $result['rule_no'] = '0165';
1109
        } /* rule: content_reject
1110
         * sample:
1111
         *   Diagnostic-Code: SMTP; 552 MessageWall: MIME/REJECT: Invalid structure
1112
         */
1113 2
        elseif (preg_match("/MIME\/REJECT/is", $diag_code)) {
1114
          $result['rule_cat'] = 'content_reject';
1115
          $result['rule_no'] = '0212';
1116
        } /* rule: content_reject
1117
         * sample:
1118
         *   Diagnostic-Code: smtp; 554 5.6.0 Message with invalid header rejected, id=13462-01 - MIME error: error: UnexpectedBound: part didn't end with expected boundary [in multipart message]; EOSToken: EOF; EOSType: EOF
1119
         */
1120 2
        elseif (preg_match('/MIME error/is', $diag_code)) {
1121
          $result['rule_cat'] = 'content_reject';
1122
          $result['rule_no'] = '0217';
1123
        } /* rule: content_reject
1124
         * sample:
1125
         *   Diagnostic-Code: SMTP; 553 Mail data refused by AISP, rule [169648].
1126
         */
1127 2
        elseif (preg_match('/Mail data refused.*AISP/is', $diag_code)) {
1128
          $result['rule_cat'] = 'content_reject';
1129
          $result['rule_no'] = '0218';
1130
        } /* rule: dns_unknown
1131
         * sample:
1132
         *   Diagnostic-Code: SMTP; 550 Host unknown
1133
         */
1134 2
        elseif (preg_match('/Host unknown/is', $diag_code)) {
1135 1
          $result['rule_cat'] = 'dns_unknown';
1136 1
          $result['rule_no'] = '0130';
1137 1
        } /* rule: dns_unknown
1138
         * sample:
1139
         *   Diagnostic-Code: SMTP; 553 Specified domain is not allowed.
1140
         */
1141 2
        elseif (preg_match('/Specified domain.*not.*allow/is', $diag_code)) {
1142
          $result['rule_cat'] = 'dns_unknown';
1143
          $result['rule_no'] = '0180';
1144
        } /* rule: dns_unknown
1145
         * sample:
1146
         *   Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to
1147
         *   111.111.11.112[111.111.11.112]: No route to host
1148
         */
1149 2
        elseif (preg_match('/No route to host/is', $diag_code)) {
1150
          $result['rule_cat'] = 'dns_unknown';
1151
          $result['rule_no'] = '0188';
1152
        } /* rule: dns_unknown
1153
         * sample:
1154
         *   Diagnostic-Code: SMTP; 550 unrouteable address
1155
         */
1156 2
        elseif (preg_match('/unrouteable address/is', $diag_code)) {
1157
          $result['rule_cat'] = 'dns_unknown';
1158
          $result['rule_no'] = '0208';
1159
        } /* rule: dns_unknown
1160
         * sample:
1161
         *   Diagnostic-Code: X-Postfix; Host or domain name not found. Name service error
1162
         *     for name=aaaaaaaaaaa type=A: Host not found
1163
         */
1164 2
        elseif (preg_match('/Host or domain name not found/is', $diag_code)) {
1165 1
          $result['rule_cat'] = 'dns_unknown';
1166 1
          $result['rule_no'] = '0238';
1167 1
        } /* rule: dns_loop
1168
         * sample:
1169
         *   Diagnostic-Code: X-Postfix; mail for mta.example.com loops back to myself
1170
         */
1171 2
        elseif (preg_match('/loops back to myself/i', $diag_code)) {
1172 1
          $result['rule_cat'] = 'dns_loop';
1173 1
          $result['rule_no'] = '0245';
1174 1
        } /* rule: defer
1175
         * sample:
1176
         *   Diagnostic-Code: SMTP; 451 System(u) busy, try again later.
1177
         */
1178 1
        elseif (preg_match('/System.*busy/is', $diag_code)) {
1179
          $result['rule_cat'] = 'defer';
1180
          $result['rule_no'] = '0112';
1181
        } /* rule: defer
1182
         * sample:
1183
         *   Diagnostic-Code: SMTP; 451 mta172.mail.tpe.domain.com Resources temporarily unavailable. Please try again later.  [#4.16.4:70].
1184
         */
1185 1
        elseif (preg_match('/Resources temporarily unavailable/is', $diag_code)) {
1186
          $result['rule_cat'] = 'defer';
1187
          $result['rule_no'] = '0116';
1188
        } /* rule: antispam, deny ip
1189
         * sample:
1190
         *   Diagnostic-Code: SMTP; 554 sender is rejected: 0,mx20,wKjR5bDrnoM2yNtEZVAkBg==.32467S2
1191
         */
1192 1
        elseif (preg_match('/sender is rejected/is', $diag_code)) {
1193
          $result['rule_cat'] = 'antispam';
1194
          $result['rule_no'] = '0101';
1195
        } /* rule: antispam, deny ip
1196
         * sample:
1197
         *   Diagnostic-Code: SMTP; 554 <unknown[111.111.111.000]>: Client host rejected: Access denied
1198
         */
1199 1
        elseif (preg_match('/Client host rejected/is', $diag_code)) {
1200
          $result['rule_cat'] = 'antispam';
1201
          $result['rule_no'] = '0102';
1202
        } /* rule: antispam, mismatch ip
1203
         * sample:
1204
         *   Diagnostic-Code: SMTP; 554 Connection refused(mx). MAIL FROM [[email protected]] mismatches client IP [111.111.111.000].
1205
         */
1206 1
        elseif (preg_match('/MAIL FROM(.*)mismatches client IP/is', $diag_code)) {
1207
          $result['rule_cat'] = 'antispam';
1208
          $result['rule_no'] = '0104';
1209
        } /* rule: antispam, deny ip
1210
         * sample:
1211
         *   Diagnostic-Code: SMTP; 554 Please visit http:// antispam.domain.com/denyip.php?IP=111.111.111.000 (#5.7.1)
1212
         */
1213 1
        elseif (preg_match('/denyip/is', $diag_code)) {
1214
          $result['rule_cat'] = 'antispam';
1215
          $result['rule_no'] = '0144';
1216
        } /* rule: antispam, deny ip
1217
         * sample:
1218
         *   Diagnostic-Code: SMTP; 554 Service unavailable; Client host [111.111.111.211] blocked using dynablock.domain.com; Your message could not be delivered due to complaints we received regarding the IP address you're using or your ISP. See http:// blackholes.domain.com/ Error: WS-02
1219
         */
1220 1
        elseif (preg_match('/client host.*blocked/is', $diag_code)) {
1221
          $result['rule_cat'] = 'antispam';
1222
          $result['rule_no'] = '0242';
1223
        } /* rule: antispam, reject
1224
         * sample:
1225
         *   Diagnostic-Code: SMTP; 550 Requested action not taken: mail IsCNAPF76kMDARUY.56621S2 is rejected,mx3,BM
1226
         */
1227 1
        elseif (preg_match('/mail.*reject/is', $diag_code)) {
1228
          $result['rule_cat'] = 'antispam';
1229
          $result['rule_no'] = '0147';
1230
        } /* rule: antispam
1231
         * sample:
1232
         *   Diagnostic-Code: SMTP; 552 sorry, the spam message is detected (#5.6.0)
1233
         */
1234 1
        elseif (preg_match('/spam.*detect/is', $diag_code)) {
1235
          $result['rule_cat'] = 'antispam';
1236
          $result['rule_no'] = '0162';
1237
        } /* rule: antispam
1238
         * sample:
1239
         *   Diagnostic-Code: SMTP; 554 5.7.1 Rejected as Spam see: http:// rejected.domain.com/help/spam/rejected.html
1240
         */
1241 1
        elseif (preg_match('/reject.*spam/is', $diag_code)) {
1242
          $result['rule_cat'] = 'antispam';
1243
          $result['rule_no'] = '0216';
1244
        } /* rule: antispam
1245
         * sample:
1246
         *   Diagnostic-Code: SMTP; 553 5.7.1 <[email protected]>... SpamTrap=reject mode, dsn=5.7.1, Message blocked by BOX Solutions (www.domain.com) SpamTrap Technology, please contact the domain.com site manager for help: (ctlusr8012).
1247
         */
1248 1
        elseif (preg_match('/SpamTrap/is', $diag_code)) {
1249
          $result['rule_cat'] = 'antispam';
1250
          $result['rule_no'] = '0200';
1251
        } /* rule: antispam, mailfrom mismatch
1252
         * sample:
1253
         *   Diagnostic-Code: SMTP; 550 Verify mailfrom failed,blocked
1254
         */
1255 1
        elseif (preg_match('/Verify mailfrom failed/is', $diag_code)) {
1256
          $result['rule_cat'] = 'antispam';
1257
          $result['rule_no'] = '0210';
1258
        } /* rule: antispam, mailfrom mismatch
1259
         * sample:
1260
         *   Diagnostic-Code: SMTP; 550 Error: MAIL FROM is mismatched with message header from address!
1261
         */
1262 1
        elseif (preg_match('/MAIL.*FROM.*mismatch/is', $diag_code)) {
1263
          $result['rule_cat'] = 'antispam';
1264
          $result['rule_no'] = '0226';
1265
        } /* rule: antispam
1266
         * sample:
1267
         *   Diagnostic-Code: SMTP; 554 5.7.1 Message scored too high on spam scale.  For help, please quote incident ID 22492290.
1268
         */
1269 1
        elseif (preg_match('/spam scale/is', $diag_code)) {
1270
          $result['rule_cat'] = 'antispam';
1271
          $result['rule_no'] = '0211';
1272
        } /* rule: antispam
1273
         * sample:
1274
         *   Diagnostic-Code: SMTP; 554 5.7.1 reject: Client host bypassing service provider's mail relay: ds176.domain.com
1275
         */
1276 1
        elseif (preg_match('/Client host bypass/is', $diag_code)) {
1277
          $result['rule_cat'] = 'antispam';
1278
          $result['rule_no'] = '0229';
1279
        } /* rule: antispam
1280
         * sample:
1281
         *   Diagnostic-Code: SMTP; 550 sorry, it seems as a junk mail
1282
         */
1283 1
        elseif (preg_match('/junk mail/is', $diag_code)) {
1284
          $result['rule_cat'] = 'antispam';
1285
          $result['rule_no'] = '0230';
1286
        } /* rule: antispam
1287
         * sample:
1288
         *   Diagnostic-Code: SMTP; 553-Message filtered. Please see the FAQs section on spam
1289
         */
1290 1
        elseif (preg_match('/message filtered/is', $diag_code)) {
1291
          $result['rule_cat'] = 'antispam';
1292
          $result['rule_no'] = '0243';
1293
        } /* rule: antispam, subject filter
1294
         * sample:
1295
         *   Diagnostic-Code: SMTP; 554 5.7.1 The message from (<[email protected]>) with the subject of ( *(ca2639) 7|-{%2E* : {2"(%EJ;y} (SBI$#$@<K*:7s1!=l~) matches a profile the Internet community may consider spam. Please revise your message before resending.
1296
         */
1297 1
        elseif (preg_match('/subject.*consider.*spam/is', $diag_code)) {
1298
          $result['rule_cat'] = 'antispam';
1299
          $result['rule_no'] = '0222';
1300
        } /* rule: internal_error
1301
         * sample:
1302
         *   Diagnostic-Code: SMTP; 451 Temporary local problem - please try later
1303
         */
1304 1
        elseif (preg_match('/Temporary local problem/is', $diag_code)) {
1305
          $result['rule_cat'] = 'internal_error';
1306
          $result['rule_no'] = '0142';
1307
        } /* rule: internal_error
1308
         * sample:
1309
         *   Diagnostic-Code: SMTP; 553 5.3.5 system config error
1310
         */
1311 1
        elseif (preg_match('/system config error/is', $diag_code)) {
1312
          $result['rule_cat'] = 'internal_error';
1313
          $result['rule_no'] = '0153';
1314
        } /* rule: delayed
1315
         * sample:
1316
         *   Diagnostic-Code: X-Postfix; delivery temporarily suspended: conversation with
1317
         *   111.111.111.11[111.111.111.11] timed out while sending end of data -- message may be
1318
         *   sent more than once
1319
         */
1320 1
        elseif (preg_match('/delivery.*suspend/is', $diag_code)) {
1321
          $result['rule_cat'] = 'delayed';
1322
          $result['rule_no'] = '0213';
1323
        }
1324
1325
        // =========== rules based on the dsn_msg ===============
1326
1327
        /* rule: unknown
1328
         * sample:
1329
         *   ----- The following addresses had permanent fatal errors -----
1330
         *   <[email protected]>
1331
         *   ----- Transcript of session follows -----
1332
         *   ... while talking to mta1.domain.com.:
1333
         *   >>> DATA
1334
         *   <<< 503 All recipients are invalid
1335
         *   554 5.0.0 Service unavailable
1336
         */
1337 1
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user)(.*)invalid/i', $dsn_msg)) {
1338
          $result['rule_cat'] = 'unknown';
1339
          $result['rule_no'] = '0107';
1340
        } /* rule: unknown
1341
         * sample:
1342
         *   ----- Transcript of session follows -----
1343
         *   [email protected]... Deferred: No such file or directory
1344
         */
1345 1
        elseif (preg_match('/Deferred.*No such.*(?:file|directory)/i', $dsn_msg)) {
1346
          $result['rule_cat'] = 'unknown';
1347
          $result['rule_no'] = '0141';
1348
        } /* rule: unknown
1349
         * sample:
1350
         *   Failed to deliver to '<[email protected]>'
1351
         *   LOCAL module(account xxxx) reports:
1352
         *   mail receiving disabled
1353
         */
1354 1
        elseif (preg_match('/mail receiving disabled/i', $dsn_msg)) {
1355
          $result['rule_cat'] = 'unknown';
1356
          $result['rule_no'] = '0194';
1357
        } /* rule: unknown
1358
         * sample:
1359
         *   - These recipients of your message have been processed by the mail server:
1360
         *   [email protected]; Failed; 5.1.1 (bad destination mailbox address)
1361
         */
1362 1
        elseif (preg_match('/bad.*(?:alias|account|recipient|address|email|mailbox|user)/i', $status_code)) {
1363
          $result['rule_cat'] = 'unknown';
1364
          $result['rule_no'] = '02441';
1365
        } /* rule: unknown
1366
         * sample:
1367
         *   - These recipients of your message have been processed by the mail server:
1368
         *   [email protected]; Failed; 5.1.1 (bad destination mailbox address)
1369
         */
1370 1
        elseif (preg_match('/bad.*(?:alias|account|recipient|address|email|mailbox|user)/i', $dsn_msg)) {
1371 1
          $result['rule_cat'] = 'unknown';
1372 1
          $result['rule_no'] = '0244';
1373 1
        } /* rule: full
1374
         * sample 1:
1375
         *   This Message was undeliverable due to the following reason:
1376
         *   The user(s) account is temporarily over quota.
1377
         *   <[email protected]>
1378
         * sample 2:
1379
         *   Recipient address: [email protected]
1380
         *   Reason: Over quota
1381
         */
1382 1
        elseif (preg_match('/over.*quota/i', $dsn_msg)) {
1383
          $result['rule_cat'] = 'full';
1384
          $result['rule_no'] = '0131';
1385
        } /* rule: full
1386
         * sample:
1387
         *   Sorry the recipient quota limit is exceeded.
1388
         *   This message is returned as an error.
1389
         */
1390 1
        elseif (preg_match('/quota.*exceeded/i', $dsn_msg)) {
1391
          $result['rule_cat'] = 'full';
1392
          $result['rule_no'] = '0150';
1393
        } /* rule: full
1394
         * sample:
1395
         *   The user to whom this message was addressed has exceeded the allowed mailbox
1396
         *   quota. Please resend the message at a later time.
1397
         */
1398 1
        elseif (preg_match("/exceed.*\n?.*quota/i", $dsn_msg)) {
1399
          $result['rule_cat'] = 'full';
1400
          $result['rule_no'] = '0187';
1401
        } /* rule: full
1402
         * sample 1:
1403
         *   Failed to deliver to '<[email protected]>'
1404
         *   LOCAL module(account xxxxxx) reports:
1405
         *   account is full (quota exceeded)
1406
         * sample 2:
1407
         *   Error in fabiomod_sql_glob_init: no data source specified - database access disabled
1408
         *   [Fri Feb 17 23:29:38 PST 2006] full error for caltsmy:
1409
         *   that member's mailbox is full
1410
         *   550 5.0.0 <[email protected]>... Can't create output
1411
         */
1412 1
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*full/i', $dsn_msg)) {
1413
          $result['rule_cat'] = 'full';
1414
          $result['rule_no'] = '0132';
1415
        } /* rule: full
1416
         * sample:
1417
         *   gaosong "(0), ErrMsg=Mailbox space not enough (space limit is 10240KB)
1418
         */
1419 1
        elseif (preg_match('/space.*not.*enough/i', $dsn_msg)) {
1420
          $result['rule_cat'] = 'full';
1421
          $result['rule_no'] = '0219';
1422
        } /* rule: defer
1423
         * sample 1:
1424
         *   ----- Transcript of session follows -----
1425
         *   [email protected]... Deferred: Connection refused by nomail.tpe.domain.com.
1426
         *   Message could not be delivered for 5 days
1427
         *   Message will be deleted from queue
1428
         * sample 2:
1429
         *   451 4.4.1 reply: read error from www.domain.com.
1430
         *   [email protected]... Deferred: Connection reset by www.domain.com.
1431
         */
1432 1
        elseif (preg_match('/Deferred.*Connection (?:refused|reset)/i', $dsn_msg)) {
1433
          $result['rule_cat'] = 'defer';
1434
          $result['rule_no'] = '0115';
1435
        } /* rule: dns_unknown
1436
         * sample:
1437
         *   ----- The following addresses had permanent fatal errors -----
1438
         *   Tan XXXX SSSS <[email protected]>
1439
         *   ----- Transcript of session follows -----
1440
         *   553 5.1.2 XXXX SSSS <[email protected]>... Invalid host name
1441
         */
1442 1
        elseif (preg_match('/Invalid host name/i', $dsn_msg)) {
1443
          $result['rule_cat'] = 'dns_unknown';
1444
          $result['rule_no'] = '0239';
1445
        } /* rule: dns_unknown
1446
         * sample:
1447
         *   ----- Transcript of session follows -----
1448
         *   [email protected]... Deferred: mail.domain.com.: No route to host
1449
         */
1450 1
        elseif (preg_match('/Deferred.*No route to host/i', $dsn_msg)) {
1451
          $result['rule_cat'] = 'dns_unknown';
1452
          $result['rule_no'] = '0240';
1453
        } /* rule: dns_unknown
1454
         * sample:
1455
         *   ----- Transcript of session follows -----
1456
         *   550 5.1.2 [email protected]... Host unknown (Name server: .: no data known)
1457
         */
1458 1
        elseif (preg_match('/Host unknown/i', $dsn_msg)) {
1459
          $result['rule_cat'] = 'dns_unknown';
1460
          $result['rule_no'] = '0140';
1461
        } /* rule: dns_unknown
1462
         * sample:
1463
         *   ----- Transcript of session follows -----
1464
         *   451 HOTMAIL.com.tw: Name server timeout
1465
         *   Message could not be delivered for 5 days
1466
         *   Message will be deleted from queue
1467
         */
1468 1
        elseif (preg_match('/Name server timeout/i', $dsn_msg)) {
1469
          $result['rule_cat'] = 'dns_unknown';
1470
          $result['rule_no'] = '0118';
1471
        } /* rule: dns_unknown
1472
         * sample:
1473
         *   ----- Transcript of session follows -----
1474
         *   [email protected]... Deferred: Connection timed out with hkfight.com.
1475
         *   Message could not be delivered for 5 days
1476
         *   Message will be deleted from queue
1477
         */
1478 1
        elseif (preg_match('/Deferred.*Connection.*tim(?:e|ed).*out/i', $dsn_msg)) {
1479
          $result['rule_cat'] = 'dns_unknown';
1480
          $result['rule_no'] = '0119';
1481
        } /* rule: dns_unknown
1482
         * sample:
1483
         *   ----- Transcript of session follows -----
1484
         *   [email protected]... Deferred: Name server: domain.com.: host name lookup failure
1485
         */
1486 1
        elseif (preg_match('/Deferred.*host name lookup failure/i', $dsn_msg)) {
1487
          $result['rule_cat'] = 'dns_unknown';
1488
          $result['rule_no'] = '0121';
1489
        } /* rule: dns_loop
1490
         * sample:
1491
         *   ----- Transcript of session follows -----
1492
         *   554 5.0.0 MX list for znet.ws. points back to mail01.domain.com
1493
         *   554 5.3.5 Local configuration error
1494
         */
1495 1
        elseif (preg_match('/MX list.*point.*back/i', $dsn_msg)) {
1496
          $result['rule_cat'] = 'dns_loop';
1497
          $result['rule_no'] = '0199';
1498
        } /* rule: internal_error
1499
         * sample:
1500
         *   ----- Transcript of session follows -----
1501
         *   451 4.0.0 I/O error
1502
         */
1503 1
        elseif (preg_match("/I\/O error/i", $dsn_msg)) {
1504
          $result['rule_cat'] = 'internal_error';
1505
          $result['rule_no'] = '0120';
1506
        } /* rule: internal_error
1507
         * sample:
1508
         *   Failed to deliver to '[email protected]'
1509
         *   SMTP module(domain domain.com) reports:
1510
         *   connection with mx1.mail.domain.com is broken
1511
         */
1512 1
        elseif (preg_match('/connection.*broken/i', $dsn_msg)) {
1513
          $result['rule_cat'] = 'internal_error';
1514
          $result['rule_no'] = '0231';
1515
        } /* rule: other
1516
         * sample:
1517
         *   Delivery to the following recipients failed.
1518
         *   [email protected]
1519
         */
1520 1
        elseif (preg_match("/Delivery to the following recipients failed.*\n.*\n.*" . $result['email'] . '/i', $dsn_msg)) {
1521
          $result['rule_cat'] = 'other';
1522
          $result['rule_no'] = '0176';
1523
        }
1524
1525
        // Followings are wind-up rule: must be the last one
1526
        //   many other rules msg end up with "550 5.1.1 ... User unknown"
1527
        //   many other rules msg end up with "554 5.0.0 Service unavailable"
1528
1529
        /* rule: unknown
1530
         * sample 1:
1531
         *   ----- The following addresses had permanent fatal errors -----
1532
         *   <[email protected]>
1533
         *   (reason: User unknown)
1534
         * sample 2:
1535
         *   550 5.1.1 [email protected]... User unknown
1536
         */
1537 1
        elseif (preg_match('/(?:User unknown|Unknown user)/i', $dsn_msg)) {
1538
          $result['rule_cat'] = 'unknown';
1539
          $result['rule_no'] = '0193';
1540
        } /* rule: unknown
1541
         * sample:
1542
         *   554 5.0.0 Service unavailable
1543
         */
1544 1
        elseif (preg_match('/Service unavailable/i', $dsn_msg)) {
1545 1
          $result['rule_cat'] = 'unknown';
1546 1
          $result['rule_no'] = '0214';
1547 1
        }
1548 2
        break;
1549
1550
      case 'delayed':
1551
        $result['rule_cat'] = 'delayed';
1552
        $result['rule_no'] = '0110';
1553
        break;
1554
1555
      case 'delivered':
1556
      case 'relayed':
1557
      case 'expanded': // unhandled cases
1558
        break;
1559
1560
      default:
1561
        break;
1562
    }
1563
  }
1564
1565 2
  global $rule_categories, $bmh_newline;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
1566 2
  if ($result['rule_no'] == '0000') {
1567 1
    if ($debug_mode) {
1568
      echo 'email: ' . $result['email'] . $bmh_newline;
1569
      echo 'Action: ' . $action . $bmh_newline;
1570
      echo 'Status: ' . $status_code . $bmh_newline;
1571
      echo 'Diagnostic-Code: ' . $diag_code . $bmh_newline;
1572
      echo "DSN Message:<br />\n" . $dsn_msg . $bmh_newline;
1573
      echo $bmh_newline;
1574
    }
1575 1 View Code Duplication
  } else {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1576 2
    if ($result['bounce_type'] === false) {
1577 2
      $result['bounce_type'] = $rule_categories[$result['rule_cat']]['bounce_type'];
1578 2
      $result['remove'] = $rule_categories[$result['rule_cat']]['remove'];
1579 2
    }
1580
  }
1581
1582 2
  return $result;
1583
}
1584