Completed
Push — master ( df833b...aa6f85 )
by Lars
27:08 queued 25:09
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 197
CRAP Score 143

Importance

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

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.5-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 1
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 1
    '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 1
$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, /** @noinspection PhpUnusedParameterInspection */ $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
      'bounce_type'     => false,
79
      'remove'          => 0,
80
      'rule_cat'        => 'unrecognized',
81
      'rule_no'         => '0000',
82
      'status_code'     => '',
83
      'action'          => '',
84
      'diagnostic_code' => '',
85
  );
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
  } /* Gmail Bounce Error
106
   * rule: unknown
107
   * sample:
108
   *   Delivery to the following recipient failed permanently:
109
   *   [email protected]
110
   */
111 2 View Code Duplication
  elseif (preg_match("/Delivery to the following (?:recipient|recipients) failed permanently\X*?(\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...
112 1
    $result['rule_cat'] = 'unknown';
113 1
    $result['rule_no'] = '0998';
114 1
    $result['email'] = $match[1];
115
  } /*
116
   * rule: unknown
117
   * sample:
118
   * <[email protected]>: host mail-host[111.111.111.111]
119
    said: 550 5.1.1 This user does not exist
120
   */
121 2
  elseif (preg_match("/user.+?not\s+exist/i", $body, $match)) {
122
    $result['rule_cat'] = 'unknown';
123
    $result['rule_no'] = '02361';
124
  } /* rule: unknown
125
   * sample:
126
   *   <[email protected]>:
127
   *   111.111.111.111 does not like recipient.
128
   *   Remote host said: 550 User unknown
129
   */
130 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...
131 1
    $result['rule_cat'] = 'unknown';
132 1
    $result['rule_no'] = '0236';
133
  } /* rule: unknown
134
   * sample:
135
   *
136
   */
137 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...
138 2
    $result['rule_cat'] = 'unknown';
139 2
    $result['rule_no'] = '0249';
140
  } /* rule: unknown
141
   * sample:
142
   *   <[email protected]>:
143
   *   Sorry, no mailbox here by that name. vpopmail (#5.1.1)
144
   */
145 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...
146
    $result['rule_cat'] = 'unknown';
147
    $result['rule_no'] = '0157';
148
  } /* rule: unknown
149
   * sample:
150
   *   [email protected]<br>
151
   *   local: Sorry, can't find user's mailbox. (#5.1.1)<br>
152
   */
153 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...
154
    $result['rule_cat'] = 'unknown';
155
    $result['rule_no'] = '0164';
156
  } /* rule: unknown
157
   * sample:
158
   *   ##########################################################
159
   *   #  This is an automated response from a mail delivery    #
160
   *   #  program.  Your message could not be delivered to      #
161
   *   #  the following address:                                #
162
   *   #                                                        #
163
   *   #      "|/usr/local/bin/mailfilt -u #dkms"               #
164
   *   #        (reason: Can't create output)                   #
165
   *   #        (expanded from: <[email protected]>)         #
166
   *   #                                                        #
167
   */
168 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...
169
    $result['rule_cat'] = 'unknown';
170
    $result['rule_no'] = '0169';
171
    $result['email'] = $match[1];
172
  } /* 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...
173
   * sample:
174
   *   ????????????????:
175
   *   [email protected] : ????, ?????.
176
   */
177 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...
178
    $result['rule_cat'] = 'unknown';
179
    $result['rule_no'] = '0174';
180
  } /* rule: unknown
181
   * sample:
182
   *   [email protected]
183
   *   Unrouteable address
184
   */
185 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...
186
    $result['rule_cat'] = 'unknown';
187
    $result['rule_no'] = '0179';
188
  } /* rule: unknown
189
   * sample:
190
   *   Delivery to the following recipients failed.
191
   *   [email protected]
192
   */
193 1 View Code Duplication
  elseif (preg_match("/delivery[^\n\r]+failed\S*\s+(\S+@\S+\w)\s/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...
194
    $result['rule_cat'] = 'unknown';
195
    $result['rule_no'] = '0013';
196
    $result['email'] = $match[1];
197
  } /* rule: unknown
198
   * sample:
199
   *   A message that you sent could not be delivered to one or more of its
200
   *   recipients. This is a permanent error. The following address(es) failed:
201
   *
202
   *   [email protected]
203
   *   unknown local-part "xxxxx" in domain "yourdomain.com"
204
   */
205 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...
206
    $result['rule_cat'] = 'unknown';
207
    $result['rule_no'] = '0232';
208
  } /* rule: unknown
209
   * sample:
210
   *   <[email protected]>:
211
   *   111.111.111.11 does not like recipient.
212
   *   Remote host said: 550 Invalid recipient: <[email protected]>
213
   */
214 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...
215
    $result['rule_cat'] = 'unknown';
216
    $result['rule_no'] = '0233';
217
    $result['email'] = $match[1];
218
  } /* rule: unknown
219
   * sample:
220
   *   Sent >>> RCPT TO: <[email protected]>
221
   *   Received <<< 550 [email protected]... No such user
222
   *
223
   *   Could not deliver mail to this user.
224
   *   [email protected]
225
   *   *****************     End of message     ***************
226
   */
227 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...
228
    $result['rule_cat'] = 'unknown';
229
    $result['rule_no'] = '0234';
230
    $result['email'] = $match[1];
231
  } /* rule: unknown
232
   * sample:
233
   *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
234
   */
235 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...
236
    $result['rule_cat'] = 'unknown';
237
    $result['rule_no'] = '0254';
238
  } /* rule: full
239
   * sample 1:
240
   *   <[email protected]>:
241
   *   This account is over quota and unable to receive mail.
242
   *   sample 2:
243
   *   <[email protected]>:
244
   *   Warning: undefined mail delivery mode: normal (ignored).
245
   *   The users mailfolder is over the allowed quota (size). (#5.2.2)
246
   */
247 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...
248
    $result['rule_cat'] = 'full';
249
    $result['rule_no'] = '0182';
250
  } /* rule: full
251
   * sample:
252
   *   ----- Transcript of session follows -----
253
   *   mail.local: /var/mail/2b/10/kellen.lee: Disc quota exceeded
254
   *   554 <[email protected]>... Service unavailable
255
   */
256 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...
257
    $result['rule_cat'] = 'full';
258
    $result['rule_no'] = '0126';
259
    $result['email'] = $match[1];
260
  } /* rule: full
261
   * sample:
262
   *   Hi. This is the qmail-send program at 263.domain.com.
263
   *   <[email protected]>:
264
   *   - User disk quota exceeded. (#4.3.0)
265
   */
266 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...
267
    $result['rule_cat'] = 'full';
268
    $result['rule_no'] = '0158';
269
  } /* rule: full
270
   * sample:
271
   *   [email protected]
272
   *   mailbox is full (MTA-imposed quota exceeded while writing to file /mbx201/mbx011/A100/09/35/A1000935772/mail/.inbox):
273
   */
274 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...
275
    $result['rule_cat'] = 'full';
276
    $result['rule_no'] = '0166';
277
  } /* rule: full
278
   * sample:
279
   *   The message to [email protected] is bounced because : Quota exceed the hard limit
280
   */
281 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...
282
    $result['rule_cat'] = 'full';
283
    $result['rule_no'] = '0168';
284
    $result['email'] = $match[1];
285
  } /* rule: full
286
   * sample:
287
   *   Message rejected. Not enough storage space in user's mailbox to accept message.
288
   */
289 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...
290
    $result['rule_cat'] = 'full';
291
    $result['rule_no'] = '0253';
292
  } /* rule: inactive
293
   * sample:
294
   *   [email protected]<br>
295
   *   553 user is inactive (eyou mta)
296
   */
297 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...
298
    $result['rule_cat'] = 'inactive';
299
    $result['rule_no'] = '0171';
300
  } /*
301
   * <[email protected]> is restricted
302
   */
303 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...
304
    $result['rule_cat'] = 'inactive';
305
    $result['rule_no'] = '0201';
306
    $result['email'] = $match[1];
307
  } /* rule: inactive
308
   * sample:
309
   *   [email protected] [Inactive account]
310
   */
311 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...
312
    $result['rule_cat'] = 'inactive';
313
    $result['rule_no'] = '0181';
314
  } /*
315
   *<[email protected]>: host mx3.HOTMAIL.COM said: 550
316
   * Requested action not taken: mailbox unavailable (in reply to RCPT TO command)
317
   */
318 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...
319
    $result['rule_cat'] = 'unknown';
320
    $result['rule_no'] = '124';
321
    $result['email'] = $match[1];
322
  } /*
323
   * rule: mailbox unknown;
324
   * sample:
325
   * [email protected]
326
   * 550-5.1.1 The email
327
   * account that you tried to reach does not exist. Please try 550-5.1.1
328
   * double-checking the recipient's email address for typos or 550-5.1.1
329
   * unnecessary spaces. Learn more at 550 5.1.1
330
   * http://support.google.com/mail/bin/answer.py?answer=6596 n7si4762785wiy.46
331
   * (in reply to RCPT TO command)
332
   */
333 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...
334
    $result['rule_cat'] = 'unknown';
335
    $result['rule_no'] = '7770';
336
    $result['email'] = $match[1];
337
  } /* rule: dns_unknown
338
   * sample1:
339
   *   Delivery to the following recipient failed permanently:
340
   *
341
   *     [email protected]
342
   *
343
   *   Technical details of permanent failure:
344
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
345
   *   [b.c (1): Connection timed out]
346
   * sample2:
347
   *   Delivery to the following recipient failed permanently:
348
   *
349
   *     [email protected]
350
   *
351
   *   Technical details of permanent failure:
352
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
353
   *   [pop.b.c (1): Connection dropped]
354
   */
355 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...
356
    $result['rule_cat'] = 'dns_unknown';
357
    $result['rule_no'] = '0251';
358
  } /* rule: delayed
359
   * sample:
360
   *   Delivery to the following recipient has been delayed:
361
   *
362
   *     [email protected]
363
   *
364
   *   Message will be retried for 2 more day(s)
365
   *
366
   *   Technical details of temporary failure:
367
   *   TEMP_FAILURE: Could not initiate SMTP conversation with any hosts:
368
   *   [b.c (50): Connection timed out]
369
   */
370 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...
371
    $result['rule_cat'] = 'delayed';
372
    $result['rule_no'] = '0252';
373
  } /* rule: delayed
374
   * sample:
375
   *   Delivery to the following recipient has been delayed:
376
   *
377
   *     [email protected]
378
   *
379
   *   Message will be retried for 2 more day(s)
380
   *
381
   *   Technical details of temporary failure:
382
   *   TEMP_FAILURE: The recipient server did not accept our requests to connect. Learn more at ...
383
   *   [b.c (10): Connection dropped]
384
   */
385 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...
386
    $result['rule_cat'] = 'delayed';
387
    $result['rule_no'] = '0256';
388
  } /* rule: internal_error
389
   * sample:
390
   *   <[email protected]>:
391
   *   Unable to switch to /var/vpopmail/domains/domain.com: input/output error. (#4.3.0)
392
   */
393 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...
394
    $result['rule_cat'] = 'internal_error';
395
    $result['rule_no'] = '0172';
396
    $result['bounce_type'] = 'hard';
397
    $result['remove'] = 1;
398
  } /* rule: internal_error
399
   * sample:
400
   *   <[email protected]>:
401
   *   can not open new email file errno=13 file=/home/vpopmail/domains/fromc.com/0/domain/Maildir/tmp/1155254417.28358.mx05,S=212350
402
   */
403 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...
404
    $result['rule_cat'] = 'internal_error';
405
    $result['rule_no'] = '0173';
406
    $result['bounce_type'] = 'hard';
407
    $result['remove'] = 1;
408
  } /* rule: defer
409
   * sample:
410
   *   <[email protected]>:
411
   *   111.111.111.111 failed after I sent the message.
412
   *   Remote host said: 451 mta283.mail.scd.yahoo.com Resources temporarily unavailable. Please try again later [#4.16.5].
413
   */
414 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...
415
    $result['rule_cat'] = 'defer';
416
    $result['rule_no'] = '0163';
417
  } /* rule: autoreply
418
   * sample:
419
   *   AutoReply message from [email protected]
420
   */
421 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...
422
    $result['rule_cat'] = 'autoreply';
423
    $result['rule_no'] = '0167';
424
    $result['email'] = $match[1];
425
  } /* rule: block
426
   * sample:
427
   *   Delivery to the following recipient failed permanently:
428
   *     [email protected]
429
   *   Technical details of permanent failure:
430
   *   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.
431
   */
432 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...
433
    $result['rule_cat'] = 'antispam';
434
    $result['rule_no'] = '0250';
435
  } /* rule: content_reject
436
   * sample:
437
   *   Failed to deliver to '<[email protected]>'
438
   *   Messages without To: fields are not accepted here
439
   */
440 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...
441 1
    $result['rule_cat'] = 'content_reject';
442 1
    $result['rule_no'] = '0248';
443
  }  /* rule: inactive
444
   * sample:
445
   *   <[email protected]>:
446
   *   This address no longer accepts mail.
447
   */
448 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...
449
    $result['rule_cat'] = 'inactive';
450
    $result['rule_no'] = '0235';
451
  } /* rule: western chars only
452
   * sample:
453
   *   <[email protected]>:
454
   *   The user does not accept email in non-Western (non-Latin) character sets.
455
   */
456 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...
457
    $result['rule_cat'] = 'latin_only';
458
    $result['rule_no'] = '0043';
459
  } /* rule: unknown
460
   * sample:
461
   *   554 delivery error
462
   *   This user doesn't have a yahoo.com account
463
   */
464 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...
465
    $result['rule_cat'] = 'unknown';
466
    $result['rule_no'] = '0044';
467
  } /* rule: unknown
468
   * sample:
469
   *   550 hotmail.com
470
   */
471 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...
472
    $result['rule_cat'] = 'unknown';
473
    $result['rule_no'] = '0045';
474
  } /* rule: unknown
475
   * sample:
476
   *   550 5.1.1 aim.com
477
   */
478 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...
479
    $result['rule_cat'] = 'unknown';
480
    $result['rule_no'] = '0046';
481
  } /* rule: unknown
482
   * sample:
483
   *   550 .* (in reply to end of DATA command)
484
   */
485 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...
486
    $result['rule_cat'] = 'unknown';
487
    $result['rule_no'] = '0047';
488
  } /* rule: unknown
489
   * sample:
490
   *   550 .* (in reply to RCPT TO command)
491
   */
492 1
  elseif (preg_match('/550.*in reply to RCPT TO command/i', $body, $match)) {
493
    $result['rule_cat'] = 'unknown';
494
    $result['rule_no'] = '0048';
495
  } /* rule: dns_unknown
496
   * sample:
497
   *    [email protected]:
498
   *      unrouteable mail domain "b.c"
499
   */
500 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...
501 1
    $result['rule_cat'] = 'dns_unknown';
502 1
    $result['rule_no'] = '0247';
503
  }
504
505 2
  if ($result['rule_no'] !== '0000' && $result['email'] === '') {
506 2
    $preBody = substr($body, 0, strpos($body, $match[0]));
507
508 2
    $count = preg_match_all('/(\S+@\S+)/', $preBody, $match);
509 2
    if ($count) {
510 2
      $result['email'] = trim($match[1][$count - 1], "'\"()<>.:; \t\r\n\0\x0B");
511
    }
512
  }
513
514 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...
515 2
  if ($result['rule_no'] == '0000') {
516 1
    if ($debug_mode) {
517
      echo 'Body:' . $bmh_newline . $body . $bmh_newline;
518 1
      echo $bmh_newline;
519
    }
520 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...
521 2
    if ($result['bounce_type'] === false) {
522 2
      $result['bounce_type'] = $rule_categories[$result['rule_cat']]['bounce_type'];
523 2
      $result['remove'] = $rule_categories[$result['rule_cat']]['remove'];
524
    }
525
  }
526
527 2
  return $result;
528
}
529
530
/**
531
 * Defined bounce parsing rules for standard DSN (Delivery Status Notification)
532
 *
533
 * @param string  $dsn_msg    human-readable explanation
534
 * @param string  $dsn_report delivery-status report
535
 * @param boolean $debug_mode show debug info. or not
536
 *
537
 * @return array    $result an array include the following fields: 'email', 'bounce_type','remove','rule_no','rule_cat'
538
 *                      if we could NOT detect the type of bounce, return rule_no = '0000'
539
 */
540
function bmhDSNRules($dsn_msg, $dsn_report, $debug_mode = false)
541
{
542
  // initialize the result array
543
  $result = array(
544 2
      'email'           => '',
545
      'bounce_type'     => false,
546
      'remove'          => 0,
547
      'rule_cat'        => 'unrecognized',
548
      'rule_no'         => '0000',
549
      'status_code'     => '',
550
      'action'          => '',
551
      'diagnostic_code' => '',
552
  );
553 2
  $action = false;
554 2
  $status_code = false;
555 2
  $diag_code = false;
556
557
  // ======= parse $dsn_report ======
558
  // get the recipient email
559 2
  if (preg_match('/Original-Recipient: rfc822;(.*)/i', $dsn_report, $match)) {
560 1
    $email = trim($match[1], "<> \t\r\n\0\x0B");
561
    /** @noinspection PhpUsageOfSilenceOperatorInspection */
562 1
    $email_arr = @imap_rfc822_parse_adrlist($email, 'default.domain.name');
563 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...
564 1
      $result['email'] = $email_arr[0]->mailbox . '@' . $email_arr[0]->host;
565
    }
566 2
  } elseif (preg_match('/Final-Recipient: rfc822;(.*)/i', $dsn_report, $match)) {
567 2
    $email = trim($match[1], "<> \t\r\n\0\x0B");
568
    /** @noinspection PhpUsageOfSilenceOperatorInspection */
569 2
    $email_arr = @imap_rfc822_parse_adrlist($email, 'default.domain.name');
570 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...
571 2
      $result['email'] = $email_arr[0]->mailbox . '@' . $email_arr[0]->host;
572
    }
573
  }
574
575 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...
576 2
    $action = strtolower(trim($match[1]));
577 2
    $result['action'] = $action;
578
  }
579
580 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...
581 2
    $status_code = $match[1];
582 2
    $result['status_code'] = $status_code;
583
  }
584
585
  // Could be multi-line , if the new line is beginning with SPACE or HTAB
586 2
  if (preg_match("/Diagnostic-Code:((?:[^\n]|\n[\t ])+)(?:\n[^\t ]|$)/i", $dsn_report, $match)) {
587 2
    $diag_code = $match[1];
588
  }
589
590
  // No Diagnostic-Code in email, use dsn message
591 2
  if (empty($diag_code)) {
592 2
    $diag_code = $dsn_msg;
593
  }
594
595 2
  $result['diagnostic_code'] = $diag_code;
596
597
  // ======= rules ======
598
599 2
  if (empty($result['email'])) {
600
    /* email address is empty
601
     * rule: full
602
     * sample:   DSN Message only
603
     * User quota exceeded: SMTP <[email protected]>
604
     */
605 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...
606
      $result['rule_cat'] = 'full';
607
      $result['rule_no'] = '0161';
608 1
      $result['email'] = $match[1];
609
    }
610
  } else {
611
    /* action could be one of them as RFC:1894
612
     * "failed" / "delayed" / "delivered" / "relayed" / "expanded"
613
     */
614
    switch ($action) {
615 2
      case 'failed':
616
        /* rule: full
617
         * sample:
618
         *   Diagnostic-Code: X-Postfix; me.domain.com platform: said: 552 5.2.2 Over
619
         *     quota (in reply to RCPT TO command)
620
         */
621 2
        if (preg_match('/over.*quota/is', $diag_code)) {
622 1
          $result['rule_cat'] = 'full';
623 1
          $result['rule_no'] = '0105';
624
        } /* rule: full
625
         * sample:
626
         *   Diagnostic-Code: SMTP; 552 Requested mailbox exceeds quota.
627
         */
628 2
        elseif (preg_match('/exceed.*quota/is', $diag_code)) {
629
          $result['rule_cat'] = 'full';
630
          $result['rule_no'] = '0129';
631
        } /* rule: full
632
         * sample 1:
633
         *   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.
634
         * sample 2:
635
         *   Diagnostic-Code: X-Postfix; host mta5.us4.domain.com.int[111.111.111.111] said:
636
         *     552 recipient storage full, try again later (in reply to RCPT TO command)
637
         * sample 3:
638
         *   Diagnostic-Code: X-HERMES; host 127.0.0.1[127.0.0.1] said: 551 bounce as<the
639
         *     destination mailbox <[email protected]> is full> queue as
640
         *     [email protected] (in reply to end of
641
         *     DATA command)
642
         */
643 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*full/is', $diag_code)) {
644 1
          $result['rule_cat'] = 'full';
645 1
          $result['rule_no'] = '0145';
646
        } /* rule: full
647
         * sample:
648
         *   Diagnostic-Code: SMTP; 452 Insufficient system storage
649
         */
650 2
        elseif (preg_match('/Insufficient system storage/i', $diag_code)) {
651
          $result['rule_cat'] = 'full';
652
          $result['rule_no'] = '0134';
653
        } /* rule: full
654
         * sample:
655
         *   Diagnostic-Code: SMTP; 422 Benutzer hat zuviele Mails auf dem Server
656
         */
657 2
        elseif (preg_match('/Benutzer hat zuviele Mails auf dem Server/i', $diag_code)) {
658
          $result['rule_cat'] = 'full';
659
          $result['rule_no'] = '0998';
660
        } /* rule: full
661
         * sample:
662
         *   Diagnostic-Code: SMTP; 422 exceeded storage allocation
663
         */
664 2
        elseif (preg_match('/exceeded storage allocation/i', $diag_code)) {
665
          $result['rule_cat'] = 'full';
666
          $result['rule_no'] = '0997';
667
        } /* rule: full
668
         * sample:
669
         *   Diagnostic-Code: SMTP; 422 Mailbox quota usage exceeded
670
         */
671 2
        elseif (preg_match('/Mailbox quota usage exceeded/i', $diag_code)) {
672
          $result['rule_cat'] = 'full';
673
          $result['rule_no'] = '0996';
674
        } /* rule: full
675
         * sample:
676
         *   Diagnostic-Code: SMTP; 422 User has exhausted allowed storage space
677
         */
678 2
        elseif (preg_match('/User has exhausted allowed storage space/i', $diag_code)) {
679
          $result['rule_cat'] = 'full';
680
          $result['rule_no'] = '0995';
681
        } /* rule: full
682
         * sample:
683
         *   Diagnostic-Code: SMTP; 422 User mailbox exceeds allowed size
684
         */
685 2
        elseif (preg_match('/User mailbox exceeds allowed size/i', $diag_code)) {
686
          $result['rule_cat'] = 'full';
687
          $result['rule_no'] = '0994';
688
        } /* rule: full
689
         * sample:
690
         *   Diagnostic-Code: smpt; 552 Account(s) <[email protected]> does not have enough space
691
         */
692 2
        elseif (preg_match("/not.*enough\s+space/i", $diag_code)) {
693 1
          $result['rule_cat'] = 'full';
694 1
          $result['rule_no'] = '0246';
695
        } /* rule: full
696
         * sample 1:
697
         *   Diagnostic-Code: X-Postfix; cannot append message to destination file
698
         *     /var/mail/dale.me89g: error writing message: File too large
699
         * sample 2:
700
         *   Diagnostic-Code: X-Postfix; cannot access mailbox /var/spool/mail/b8843022 for
701
         *     user xxxxx. error writing message: File too large
702
         */
703 2
        elseif (preg_match('/File too large/i', $diag_code)) {
704
          $result['rule_cat'] = 'full';
705
          $result['rule_no'] = '0192';
706
        } /* rule: oversize
707
         * sample:
708
         *   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.
709
         */
710 2
        elseif (preg_match('/larger than.*limit/is', $diag_code)) {
711
          $result['rule_cat'] = 'oversize';
712
          $result['rule_no'] = '0146';
713
        } /* rule: unknown
714
         * sample:
715
         *   Diagnostic-Code: X-Notes; User xxxxx ([email protected]) not listed in public Name & Address Book
716
         */
717 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user)(.*)not(.*)list/is', $diag_code)) {
718 1
          $result['rule_cat'] = 'unknown';
719 1
          $result['rule_no'] = '0103';
720
        } /* rule: unknown
721
         * sample:
722
         *   Diagnostic-Code: smtp; 450 user path no exist
723
         */
724 2
        elseif (preg_match('/user path no exist/i', $diag_code)) {
725
          $result['rule_cat'] = 'unknown';
726
          $result['rule_no'] = '0106';
727
        } /* rule: unknown
728
         * sample 1:
729
         *   Diagnostic-Code: SMTP; 550 Relaying denied.
730
         * sample 2:
731
         *   Diagnostic-Code: SMTP; 554 <[email protected]>: Relay access denied
732
         * sample 3:
733
         *   Diagnostic-Code: SMTP; 550 relaying to <[email protected]> prohibited by administrator
734
         */
735 2
        elseif (preg_match('/Relay.*(?:denied|prohibited)/is', $diag_code)) {
736 1
          $result['rule_cat'] = 'unknown';
737 1
          $result['rule_no'] = '0108';
738
        } /* rule: unknown
739
         * sample:
740
         *   Diagnostic-Code: SMTP; 554 qq Sorry, no valid recipients (#5.1.3)
741
         */
742 2
        elseif (preg_match('/no.*valid.*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
743
          $result['rule_cat'] = 'unknown';
744
          $result['rule_no'] = '0185';
745
        } /* rule: unknown
746
         * sample 1:
747
         *   Diagnostic-Code: SMTP; 550 «Dªk¦a§} - invalid address (#5.5.0)
748
         * sample 2:
749
         *   Diagnostic-Code: SMTP; 550 Invalid recipient: <[email protected]>
750
         * sample 3:
751
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: Invalid User
752
         */
753 2
        elseif (preg_match('/Invalid.*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
754 1
          $result['rule_cat'] = 'unknown';
755 1
          $result['rule_no'] = '0111';
756
        } /* rule: unknown
757
         * sample:
758
         *   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
759
         */
760 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*(?:disabled|discontinued)/is', $diag_code)) {
761 1
          $result['rule_cat'] = 'unknown';
762 1
          $result['rule_no'] = '0114';
763
        } /* rule: unknown
764
         * sample:
765
         *   Diagnostic-Code: SMTP; 554 delivery error: dd This user doesn't have a domain.com account ([email protected]) [0] - mta134.mail.tpe.domain.com
766
         */
767 2
        elseif (preg_match("/user doesn't have.*account/is", $diag_code)) {
768 2
          $result['rule_cat'] = 'unknown';
769 2
          $result['rule_no'] = '0127';
770
        } /* rule: unknown
771
         * sample:
772
         *   Diagnostic-Code: SMTP; 550 5.1.1 unknown or illegal alias: [email protected]
773
         */
774 2
        elseif (preg_match('/(?:unknown|illegal).*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
775 2
          $result['rule_cat'] = 'unknown';
776 2
          $result['rule_no'] = '0128';
777
        } /* rule: unknown
778
         * sample 1:
779
         *   Diagnostic-Code: SMTP; 450 mailbox unavailable.
780
         * sample 2:
781
         *   Diagnostic-Code: SMTP; 550 5.7.1 Requested action not taken: mailbox not available
782
         */
783 2
        elseif (preg_match("/(?:alias|account|recipient|address|email|mailbox|user).*(?:un|not\s+)available/is", $diag_code)) {
784 1
          $result['rule_cat'] = 'unknown';
785 1
          $result['rule_no'] = '0122';
786
        } /* rule: unknown
787
         * sample:
788
         *   Diagnostic-Code: SMTP; 553 sorry, no mailbox here by that name (#5.7.1)
789
         */
790 2
        elseif (preg_match('/no (?:alias|account|recipient|address|email|mailbox|user)/i', $diag_code)) {
791 1
          $result['rule_cat'] = 'unknown';
792 1
          $result['rule_no'] = '0123';
793
        } /* rule: unknown
794
         * sample 1:
795
         *   Diagnostic-Code: SMTP; 550 User ([email protected]) unknown.
796
         * sample 2:
797
         *   Diagnostic-Code: SMTP; 553 5.3.0 <[email protected]>... Addressee unknown, relay=[111.111.111.000]
798
         */
799 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*unknown/is', $diag_code)) {
800 1
          $result['rule_cat'] = 'unknown';
801 1
          $result['rule_no'] = '0125';
802
        } /* rule: unknown
803
         * sample 1:
804
         *   Diagnostic-Code: SMTP; 550 user disabled
805
         * sample 2:
806
         *   Diagnostic-Code: SMTP; 452 4.2.1 mailbox temporarily disabled: [email protected]
807
         */
808 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*disabled/is', $diag_code)) {
809
          $result['rule_cat'] = 'unknown';
810
          $result['rule_no'] = '0133';
811
        } /* rule: unknown
812
         * sample:
813
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: Recipient address rejected: No such user ([email protected])
814
         */
815 2
        elseif (preg_match('/No such (?:alias|account|recipient|address|email|mailbox|user)/i', $diag_code)) {
816
          $result['rule_cat'] = 'unknown';
817
          $result['rule_no'] = '0143';
818
        } /* rule: unknown
819
         * sample 1:
820
         *   Diagnostic-Code: SMTP; 550 MAILBOX NOT FOUND
821
         * sample 2:
822
         *   Diagnostic-Code: SMTP; 550 Mailbox ( [email protected] ) not found or inactivated
823
         */
824 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*NOT FOUND/is', $diag_code)) {
825
          $result['rule_cat'] = 'unknown';
826
          $result['rule_no'] = '0136';
827
        } /* rule: unknown
828
         * sample:
829
         *    Diagnostic-Code: X-Postfix; host m2w-in1.domain.com[111.111.111.000] said: 551
830
         *    <[email protected]> is a deactivated mailbox (in reply to RCPT TO
831
         *    command)
832
         */
833 2
        elseif (preg_match('/deactivated (?:alias|account|recipient|address|email|mailbox|user)/i', $diag_code)) {
834
          $result['rule_cat'] = 'unknown';
835
          $result['rule_no'] = '0138';
836
        } /* rule: unknown
837
         * sample:
838
         *   Diagnostic-Code: SMTP; 550 <[email protected]> recipient rejected
839
         *   ...
840
         *   <<< 550 <[email protected]> recipient rejected
841
         *   550 5.1.1 [email protected]... User unknown
842
         */
843 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*reject/is', $diag_code)) {
844 2
          $result['rule_cat'] = 'unknown';
845 2
          $result['rule_no'] = '0148';
846
        } /* rule: unknown
847
         * sample:
848
         *   Diagnostic-Code: smtp; 5.x.0 - Message bounced by administrator  (delivery attempts: 0)
849
         */
850 2
        elseif (preg_match('/bounce.*administrator/is', $diag_code)) {
851
          $result['rule_cat'] = 'unknown';
852
          $result['rule_no'] = '0151';
853
        } /* rule: unknown
854
         * sample:
855
         *   Diagnostic-Code: SMTP; 550 <maxqin> is now disabled with MTA service.
856
         */
857 2
        elseif (preg_match('/<.*>.*disabled/is', $diag_code)) {
858
          $result['rule_cat'] = 'unknown';
859
          $result['rule_no'] = '0152';
860
        } /* rule: unknown
861
         * sample:
862
         *   Diagnostic-Code: SMTP; 551 not our customer
863
         */
864 2
        elseif (preg_match('/not our customer/i', $diag_code)) {
865
          $result['rule_cat'] = 'unknown';
866
          $result['rule_no'] = '0154';
867
        } /* rule: unknown
868
         * sample:
869
         *   Diagnostic-Code: smtp; 5.1.0 - Unknown address error 540-'Error: Wrong recipients' (delivery attempts: 0)
870
         */
871 2
        elseif (preg_match('/Wrong (?:alias|account|recipient|address|email|mailbox|user)/i', $diag_code)) {
872
          $result['rule_cat'] = 'unknown';
873
          $result['rule_no'] = '0159';
874
        } /* rule: unknown
875
         * sample:
876
         *   Diagnostic-Code: smtp; 5.1.0 - Unknown address error 540-'Error: Wrong recipients' (delivery attempts: 0)
877
         * sample 2:
878
         *   Diagnostic-Code: SMTP; 501 #5.1.1 bad address [email protected]
879
         */
880 2
        elseif (preg_match('/(?:unknown|bad).*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
881
          $result['rule_cat'] = 'unknown';
882
          $result['rule_no'] = '0160';
883
        } /* rule: unknown
884
         * sample:
885
         *   Status: 5.1.1 (bad destination mailbox address)
886
         */
887 2
        elseif (preg_match('/(?:unknown|bad).*(?:alias|account|recipient|address|email|mailbox|user)/is', $status_code)) {
888
          $result['rule_cat'] = 'unknown';
889
          $result['rule_no'] = '01601';
890
        } /* rule: unknown
891
         * sample:
892
         *   Diagnostic-Code: SMTP; 550 Command RCPT User <[email protected]> not OK
893
         */
894 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*not OK/is', $diag_code)) {
895
          $result['rule_cat'] = 'unknown';
896
          $result['rule_no'] = '0186';
897
        } /* rule: unknown
898
         * sample:
899
         *   Diagnostic-Code: SMTP; 550 5.7.1 Access-Denied-XM.SSR-001
900
         */
901 2
        elseif (preg_match('/Access.*Denied/is', $diag_code)) {
902
          $result['rule_cat'] = 'unknown';
903
          $result['rule_no'] = '0189';
904
        } /* rule: unknown
905
         * sample:
906
         *   Diagnostic-Code: SMTP; 550 5.1.1 <[email protected]>... email address lookup in domain map failed
907
         */
908 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*lookup.*fail/is', $diag_code)) {
909
          $result['rule_cat'] = 'unknown';
910
          $result['rule_no'] = '0195';
911
        } /* rule: unknown
912
         * sample:
913
         *   Diagnostic-Code: SMTP; 550 User not a member of domain: <[email protected]>
914
         */
915 2
        elseif (preg_match('/(?:recipient|address|email|mailbox|user).*not.*member of domain/is', $diag_code)) {
916
          $result['rule_cat'] = 'unknown';
917
          $result['rule_no'] = '0198';
918
        } /* rule: unknown
919
         * sample:
920
         *   Diagnostic-Code: SMTP; 550-"The recipient cannot be verified.  Please check all recipients of this
921
         */
922 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*cannot be verified/is', $diag_code)) {
923
          $result['rule_cat'] = 'unknown';
924
          $result['rule_no'] = '0202';
925
        } /* rule: unknown
926
         * sample:
927
         *   Diagnostic-Code: SMTP; 550 Unable to relay for [email protected]
928
         */
929 2
        elseif (preg_match('/Unable to relay/i', $diag_code)) {
930
          $result['rule_cat'] = 'unknown';
931
          $result['rule_no'] = '0203';
932
        } /* rule: unknown
933
         * sample 1:
934
         *   Diagnostic-Code: SMTP; 550 [email protected]:user not exist
935
         * sample 2:
936
         *   Diagnostic-Code: SMTP; 550 sorry, that recipient doesn't exist (#5.7.1)
937
         */
938 2
        elseif (preg_match("/(?:alias|account|recipient|address|email|mailbox|user).*(?:n't|not) exist/is", $diag_code)) {
939 2
          $result['rule_cat'] = 'unknown';
940 2
          $result['rule_no'] = '0205';
941
        } /* rule: unknown
942
         * sample:
943
         *   Diagnostic-Code: SMTP; 550-I'm sorry but [email protected] does not have an account here. I will not
944
         */
945 2
        elseif (preg_match('/not have an account/i', $diag_code)) {
946
          $result['rule_cat'] = 'unknown';
947
          $result['rule_no'] = '0207';
948
        } /* rule: unknown
949
         * sample:
950
         *   Diagnostic-Code: SMTP; 550 This account is not [email protected]
951
         */
952 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*is not allowed/is', $diag_code)) {
953
          $result['rule_cat'] = 'unknown';
954
          $result['rule_no'] = '0220';
955
        } /* rule: unknown
956
         * sample:
957
         *   Diagnostic-Code: X-Notes; Recipient user name info ([email protected]) not unique.  Several matches found in Domino Directory.
958
         */
959 2
        elseif (preg_match('/not unique.\s+Several matches found/i', $diag_code)) {
960
          $result['rule_cat'] = 'unknown';
961
          $result['rule_no'] = '0255';
962
        } /* rule: inactive
963
         * sample:
964
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: inactive user
965
         */
966 2
        elseif (preg_match('/inactive.*(?:alias|account|recipient|address|email|mailbox|user)/is', $diag_code)) {
967
          $result['rule_cat'] = 'inactive';
968
          $result['rule_no'] = '0135';
969
        } /* rule: inactive
970
         * sample:
971
         *   Diagnostic-Code: SMTP; 550 [email protected] Account Inactive
972
         */
973 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*Inactive/is', $diag_code)) {
974
          $result['rule_cat'] = 'inactive';
975
          $result['rule_no'] = '0155';
976
        } /* rule: inactive
977
         * sample:
978
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: Recipient address rejected: Account closed due to inactivity. No forwarding information is available.
979
         */
980 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user) closed due to inactivity/i', $diag_code)) {
981
          $result['rule_cat'] = 'inactive';
982
          $result['rule_no'] = '0170';
983
        } /* rule: inactive
984
         * sample:
985
         *   Diagnostic-Code: SMTP; 550 <[email protected]>... User account not activated
986
         */
987 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user) not activated/i', $diag_code)) {
988
          $result['rule_cat'] = 'inactive';
989
          $result['rule_no'] = '0177';
990
        } /* rule: inactive
991
         * sample 1:
992
         *   Diagnostic-Code: SMTP; 550 User suspended
993
         * sample 2:
994
         *   Diagnostic-Code: SMTP; 550 account expired
995
         */
996 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*(?:suspend|expire)/is', $diag_code)) {
997
          $result['rule_cat'] = 'inactive';
998
          $result['rule_no'] = '0183';
999
        } /* rule: inactive
1000
         * sample:
1001
         *   Diagnostic-Code: SMTP; 553 5.3.0 <[email protected]>... Recipient address no longer exists
1002
         */
1003 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*no longer exist/is', $diag_code)) {
1004
          $result['rule_cat'] = 'inactive';
1005
          $result['rule_no'] = '0184';
1006
        } /* rule: inactive
1007
         * sample:
1008
         *   Diagnostic-Code: SMTP; 553 VS10-RT Possible forgery or deactivated due to abuse (#5.1.1) 111.111.111.211
1009
         */
1010 2
        elseif (preg_match('/(?:forgery|abuse)/i', $diag_code)) {
1011
          $result['rule_cat'] = 'inactive';
1012
          $result['rule_no'] = '0196';
1013
        } /* rule: inactive
1014
         * sample:
1015
         *   Diagnostic-Code: SMTP; 553 mailbox [email protected] is restricted
1016
         */
1017 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*restrict/is', $diag_code)) {
1018
          $result['rule_cat'] = 'inactive';
1019
          $result['rule_no'] = '0209';
1020
        } /* rule: inactive
1021
         * sample:
1022
         *   Diagnostic-Code: SMTP; 550 <[email protected]>: User status is locked.
1023
         */
1024 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*locked/is', $diag_code)) {
1025
          $result['rule_cat'] = 'inactive';
1026
          $result['rule_no'] = '0228';
1027
        } /* rule: user_reject
1028
         * sample:
1029
         *   Diagnostic-Code: SMTP; 553 User refused to receive this mail.
1030
         */
1031 2
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user) refused/i', $diag_code)) {
1032
          $result['rule_cat'] = 'user_reject';
1033
          $result['rule_no'] = '0156';
1034
        } /* rule: user_reject
1035
         * sample:
1036
         *   Diagnostic-Code: SMTP; 501 [email protected] Sender email is not in my domain
1037
         */
1038 2
        elseif (preg_match('/sender.*not/is', $diag_code)) {
1039
          $result['rule_cat'] = 'user_reject';
1040
          $result['rule_no'] = '0206';
1041
        } /* rule: command_reject
1042
         * sample:
1043
         *   Diagnostic-Code: SMTP; 554 Message refused
1044
         */
1045 2
        elseif (preg_match('/Message refused/i', $diag_code)) {
1046
          $result['rule_cat'] = 'command_reject';
1047
          $result['rule_no'] = '0175';
1048
        } /* rule: command_reject
1049
         * sample:
1050
         *   Diagnostic-Code: SMTP; 550 5.0.0 <[email protected]>... No permit
1051
         */
1052 2
        elseif (preg_match('/No permit/i', $diag_code)) {
1053
          $result['rule_cat'] = 'command_reject';
1054
          $result['rule_no'] = '0190';
1055
        } /* rule: command_reject
1056
         * sample:
1057
         *   Diagnostic-Code: SMTP; 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.5.3 - chkuser)
1058
         */
1059 2
        elseif (preg_match("/domain isn't in.*allowed rcpthost/is", $diag_code)) {
1060
          $result['rule_cat'] = 'command_reject';
1061
          $result['rule_no'] = '0191';
1062
        } /* rule: command_reject
1063
         * sample:
1064
         *   Diagnostic-Code: SMTP; 553 AUTH FAILED - [email protected]
1065
         */
1066 2
        elseif (preg_match('/AUTH FAILED/i', $diag_code)) {
1067
          $result['rule_cat'] = 'command_reject';
1068
          $result['rule_no'] = '0197';
1069
        } /* rule: command_reject
1070
         * sample 1:
1071
         *   Diagnostic-Code: SMTP; 550 relay not permitted
1072
         * sample 2:
1073
         *   Diagnostic-Code: SMTP; 530 5.7.1 Relaying not allowed: [email protected]
1074
         */
1075 2
        elseif (preg_match('/relay.*not.*(?:permit|allow)/is', $diag_code)) {
1076
          $result['rule_cat'] = 'command_reject';
1077
          $result['rule_no'] = '0241';
1078
        } /* rule: command_reject
1079
         * sample:
1080
         *   Diagnostic-Code: SMTP; 550 not local host domain.com, not a gateway
1081
         */
1082 2
        elseif (preg_match('/not local host/i', $diag_code)) {
1083
          $result['rule_cat'] = 'command_reject';
1084
          $result['rule_no'] = '0204';
1085
        } /* rule: command_reject
1086
         * sample:
1087
         *   Diagnostic-Code: SMTP; 500 Unauthorized relay msg rejected
1088
         */
1089 2
        elseif (preg_match('/Unauthorized relay/i', $diag_code)) {
1090
          $result['rule_cat'] = 'command_reject';
1091
          $result['rule_no'] = '0215';
1092
        } /* rule: command_reject
1093
         * sample:
1094
         *   Diagnostic-Code: SMTP; 554 Transaction failed
1095
         */
1096 2
        elseif (preg_match('/Transaction.*fail/is', $diag_code)) {
1097
          $result['rule_cat'] = 'command_reject';
1098
          $result['rule_no'] = '0221';
1099
        } /* rule: command_reject
1100
         * sample:
1101
         *   Diagnostic-Code: smtp;554 5.5.2 Invalid data in message
1102
         */
1103 2
        elseif (preg_match('/Invalid data/i', $diag_code)) {
1104
          $result['rule_cat'] = 'command_reject';
1105
          $result['rule_no'] = '0223';
1106
        } /* rule: command_reject
1107
         * sample:
1108
         *   Diagnostic-Code: SMTP; 550 Local user only or Authentication mechanism
1109
         */
1110 2
        elseif (preg_match('/Local user only/i', $diag_code)) {
1111
          $result['rule_cat'] = 'command_reject';
1112
          $result['rule_no'] = '0224';
1113
        } /* rule: command_reject
1114
         * sample:
1115
         *   Diagnostic-Code: SMTP; 550-ds176.domain.com [111.111.111.211] is currently not permitted to
1116
         *   relay through this server. Perhaps you have not logged into the pop/imap
1117
         *   server in the last 30 minutes or do not have SMTP Authentication turned on
1118
         *   in your email client.
1119
         */
1120 2
        elseif (preg_match('/not.*permit.*to/is', $diag_code)) {
1121
          $result['rule_cat'] = 'command_reject';
1122
          $result['rule_no'] = '0225';
1123
        } /* rule: content_reject
1124
         * sample:
1125
         *   Diagnostic-Code: SMTP; 550 Content reject. FAAAANsG60M9BmDT.1
1126
         */
1127 2
        elseif (preg_match('/Content reject/i', $diag_code)) {
1128
          $result['rule_cat'] = 'content_reject';
1129
          $result['rule_no'] = '0165';
1130
        } /* rule: content_reject
1131
         * sample:
1132
         *   Diagnostic-Code: SMTP; 552 MessageWall: MIME/REJECT: Invalid structure
1133
         */
1134 2
        elseif (preg_match("/MIME\/REJECT/i", $diag_code)) {
1135
          $result['rule_cat'] = 'content_reject';
1136
          $result['rule_no'] = '0212';
1137
        } /* rule: content_reject
1138
         * sample:
1139
         *   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
1140
         */
1141 2
        elseif (preg_match('/MIME error/i', $diag_code)) {
1142
          $result['rule_cat'] = 'content_reject';
1143
          $result['rule_no'] = '0217';
1144
        } /* rule: content_reject
1145
         * sample:
1146
         *   Diagnostic-Code: SMTP; 553 Mail data refused by AISP, rule [169648].
1147
         */
1148 2
        elseif (preg_match('/Mail data refused.*AISP/is', $diag_code)) {
1149
          $result['rule_cat'] = 'content_reject';
1150
          $result['rule_no'] = '0218';
1151
        } /* rule: dns_unknown
1152
         * sample:
1153
         *   Diagnostic-Code: SMTP; 550 Host unknown
1154
         */
1155 2
        elseif (preg_match('/Host unknown/i', $diag_code)) {
1156 1
          $result['rule_cat'] = 'dns_unknown';
1157 1
          $result['rule_no'] = '0130';
1158
        } /* rule: dns_unknown
1159
         * sample:
1160
         *   Diagnostic-Code: SMTP; 553 Specified domain is not allowed.
1161
         */
1162 2
        elseif (preg_match('/Specified domain.*not.*allow/is', $diag_code)) {
1163
          $result['rule_cat'] = 'dns_unknown';
1164
          $result['rule_no'] = '0180';
1165
        } /* rule: dns_unknown
1166
         * sample:
1167
         *   Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to
1168
         *   111.111.11.112[111.111.11.112]: No route to host
1169
         */
1170 2
        elseif (preg_match('/No route to host/i', $diag_code)) {
1171
          $result['rule_cat'] = 'dns_unknown';
1172
          $result['rule_no'] = '0188';
1173
        } /* rule: dns_unknown
1174
         * sample:
1175
         *   Diagnostic-Code: SMTP; 550 unrouteable address
1176
         */
1177 2
        elseif (preg_match('/unrouteable address/i', $diag_code)) {
1178
          $result['rule_cat'] = 'dns_unknown';
1179
          $result['rule_no'] = '0208';
1180
        } /* rule: dns_unknown
1181
         * sample:
1182
         *   Diagnostic-Code: X-Postfix; Host or domain name not found. Name service error
1183
         *     for name=aaaaaaaaaaa type=A: Host not found
1184
         */
1185 2
        elseif (preg_match('/Host or domain name not found/i', $diag_code)) {
1186 1
          $result['rule_cat'] = 'dns_unknown';
1187 1
          $result['rule_no'] = '0238';
1188
        } /* rule: dns_loop
1189
         * sample:
1190
         *   Diagnostic-Code: X-Postfix; mail for mta.example.com loops back to myself
1191
         */
1192 2
        elseif (preg_match('/loops back to myself/i', $diag_code)) {
1193 1
          $result['rule_cat'] = 'dns_loop';
1194 1
          $result['rule_no'] = '0245';
1195
        } /* rule: defer
1196
         * sample:
1197
         *   Diagnostic-Code: SMTP; 451 System(u) busy, try again later.
1198
         */
1199 1
        elseif (preg_match('/System.*busy/is', $diag_code)) {
1200
          $result['rule_cat'] = 'defer';
1201
          $result['rule_no'] = '0112';
1202
        } /* rule: defer
1203
         * sample:
1204
         *   Diagnostic-Code: SMTP; 451 mta172.mail.tpe.domain.com Resources temporarily unavailable. Please try again later.  [#4.16.4:70].
1205
         */
1206 1
        elseif (preg_match('/Resources temporarily unavailable/i', $diag_code)) {
1207
          $result['rule_cat'] = 'defer';
1208
          $result['rule_no'] = '0116';
1209
        } /* rule: antispam, deny ip
1210
         * sample:
1211
         *   Diagnostic-Code: SMTP; 554 sender is rejected: 0,mx20,wKjR5bDrnoM2yNtEZVAkBg==.32467S2
1212
         */
1213 1
        elseif (preg_match('/sender is rejected/i', $diag_code)) {
1214
          $result['rule_cat'] = 'antispam';
1215
          $result['rule_no'] = '0101';
1216
        } /* rule: antispam, deny ip
1217
         * sample:
1218
         *   Diagnostic-Code: SMTP; 554 <unknown[111.111.111.000]>: Client host rejected: Access denied
1219
         */
1220 1
        elseif (preg_match('/Client host rejected/i', $diag_code)) {
1221
          $result['rule_cat'] = 'antispam';
1222
          $result['rule_no'] = '0102';
1223
        } /* rule: antispam, mismatch ip
1224
         * sample:
1225
         *   Diagnostic-Code: SMTP; 554 Connection refused(mx). MAIL FROM [[email protected]] mismatches client IP [111.111.111.000].
1226
         */
1227 1
        elseif (preg_match('/MAIL FROM(.*)mismatches client IP/is', $diag_code)) {
1228
          $result['rule_cat'] = 'antispam';
1229
          $result['rule_no'] = '0104';
1230
        } /* rule: antispam, deny ip
1231
         * sample:
1232
         *   Diagnostic-Code: SMTP; 554 Please visit http:// antispam.domain.com/denyip.php?IP=111.111.111.000 (#5.7.1)
1233
         */
1234 1
        elseif (preg_match('/denyip/i', $diag_code)) {
1235
          $result['rule_cat'] = 'antispam';
1236
          $result['rule_no'] = '0144';
1237
        } /* rule: antispam, deny ip
1238
         * sample:
1239
         *   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
1240
         */
1241 1
        elseif (preg_match('/client host.*blocked/is', $diag_code)) {
1242
          $result['rule_cat'] = 'antispam';
1243
          $result['rule_no'] = '0242';
1244
        } /* rule: antispam, reject
1245
         * sample:
1246
         *   Diagnostic-Code: SMTP; 550 Requested action not taken: mail IsCNAPF76kMDARUY.56621S2 is rejected,mx3,BM
1247
         */
1248 1
        elseif (preg_match('/mail.*reject/is', $diag_code)) {
1249
          $result['rule_cat'] = 'antispam';
1250
          $result['rule_no'] = '0147';
1251
        } /* rule: antispam
1252
         * sample:
1253
         *   Diagnostic-Code: SMTP; 552 sorry, the spam message is detected (#5.6.0)
1254
         */
1255 1
        elseif (preg_match('/spam.*detect/is', $diag_code)) {
1256
          $result['rule_cat'] = 'antispam';
1257
          $result['rule_no'] = '0162';
1258
        } /* rule: antispam
1259
         * sample:
1260
         *   Diagnostic-Code: SMTP; 554 5.7.1 Rejected as Spam see: http:// rejected.domain.com/help/spam/rejected.html
1261
         */
1262 1
        elseif (preg_match('/reject.*spam/is', $diag_code)) {
1263
          $result['rule_cat'] = 'antispam';
1264
          $result['rule_no'] = '0216';
1265
        } /* rule: antispam
1266
         * sample:
1267
         *   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).
1268
         */
1269 1
        elseif (preg_match('/SpamTrap/i', $diag_code)) {
1270
          $result['rule_cat'] = 'antispam';
1271
          $result['rule_no'] = '0200';
1272
        } /* rule: antispam, mailfrom mismatch
1273
         * sample:
1274
         *   Diagnostic-Code: SMTP; 550 Verify mailfrom failed,blocked
1275
         */
1276 1
        elseif (preg_match('/Verify mailfrom failed/i', $diag_code)) {
1277
          $result['rule_cat'] = 'antispam';
1278
          $result['rule_no'] = '0210';
1279
        } /* rule: antispam, mailfrom mismatch
1280
         * sample:
1281
         *   Diagnostic-Code: SMTP; 550 Error: MAIL FROM is mismatched with message header from address!
1282
         */
1283 1
        elseif (preg_match('/MAIL.*FROM.*mismatch/is', $diag_code)) {
1284
          $result['rule_cat'] = 'antispam';
1285
          $result['rule_no'] = '0226';
1286
        } /* rule: antispam
1287
         * sample:
1288
         *   Diagnostic-Code: SMTP; 554 5.7.1 Message scored too high on spam scale.  For help, please quote incident ID 22492290.
1289
         */
1290 1
        elseif (preg_match('/spam scale/i', $diag_code)) {
1291
          $result['rule_cat'] = 'antispam';
1292
          $result['rule_no'] = '0211';
1293
        } /* rule: antispam
1294
         * sample:
1295
         *   Diagnostic-Code: SMTP; 554 5.7.1 reject: Client host bypassing service provider's mail relay: ds176.domain.com
1296
         */
1297 1
        elseif (preg_match('/Client host bypass/i', $diag_code)) {
1298
          $result['rule_cat'] = 'antispam';
1299
          $result['rule_no'] = '0229';
1300
        } /* rule: antispam
1301
         * sample:
1302
         *   Diagnostic-Code: SMTP; 550 sorry, it seems as a junk mail
1303
         */
1304 1
        elseif (preg_match('/junk mail/i', $diag_code)) {
1305
          $result['rule_cat'] = 'antispam';
1306
          $result['rule_no'] = '0230';
1307
        } /* rule: antispam
1308
         * sample:
1309
         *   Diagnostic-Code: SMTP; 553-Message filtered. Please see the FAQs section on spam
1310
         */
1311 1
        elseif (preg_match('/message filtered/i', $diag_code)) {
1312
          $result['rule_cat'] = 'antispam';
1313
          $result['rule_no'] = '0243';
1314
        } /* rule: antispam, subject filter
1315
         * sample:
1316
         *   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.
1317
         */
1318 1
        elseif (preg_match('/subject.*consider.*spam/is', $diag_code)) {
1319
          $result['rule_cat'] = 'antispam';
1320
          $result['rule_no'] = '0222';
1321
        } /* rule: internal_error
1322
         * sample:
1323
         *   Diagnostic-Code: SMTP; 451 Temporary local problem - please try later
1324
         */
1325 1
        elseif (preg_match('/Temporary local problem/i', $diag_code)) {
1326
          $result['rule_cat'] = 'internal_error';
1327
          $result['rule_no'] = '0142';
1328
        } /* rule: internal_error
1329
         * sample:
1330
         *   Diagnostic-Code: SMTP; 553 5.3.5 system config error
1331
         */
1332 1
        elseif (preg_match('/system config error/i', $diag_code)) {
1333
          $result['rule_cat'] = 'internal_error';
1334
          $result['rule_no'] = '0153';
1335
        } /* rule: delayed
1336
         * sample:
1337
         *   Diagnostic-Code: X-Postfix; delivery temporarily suspended: conversation with
1338
         *   111.111.111.11[111.111.111.11] timed out while sending end of data -- message may be
1339
         *   sent more than once
1340
         */
1341 1
        elseif (preg_match('/delivery.*suspend/is', $diag_code)) {
1342
          $result['rule_cat'] = 'delayed';
1343
          $result['rule_no'] = '0213';
1344
        }
1345
1346
        // =========== rules based on the dsn_msg ===============
1347
1348
        /* rule: unknown
1349
         * sample:
1350
         *   ----- The following addresses had permanent fatal errors -----
1351
         *   <[email protected]>
1352
         *   ----- Transcript of session follows -----
1353
         *   ... while talking to mta1.domain.com.:
1354
         *   >>> DATA
1355
         *   <<< 503 All recipients are invalid
1356
         *   554 5.0.0 Service unavailable
1357
         */
1358 1
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user)(?:.*)invalid/i', $dsn_msg)) {
1359
          $result['rule_cat'] = 'unknown';
1360
          $result['rule_no'] = '0107';
1361
        } /* rule: unknown
1362
         * sample:
1363
         *   ----- Transcript of session follows -----
1364
         *   [email protected]... Deferred: No such file or directory
1365
         */
1366 1
        elseif (preg_match('/Deferred.*No such.*(?:file|directory)/i', $dsn_msg)) {
1367
          $result['rule_cat'] = 'unknown';
1368
          $result['rule_no'] = '0141';
1369
        } /* rule: unknown
1370
         * sample:
1371
         *   Failed to deliver to '<[email protected]>'
1372
         *   LOCAL module(account xxxx) reports:
1373
         *   mail receiving disabled
1374
         */
1375 1
        elseif (preg_match('/mail receiving disabled/i', $dsn_msg)) {
1376
          $result['rule_cat'] = 'unknown';
1377
          $result['rule_no'] = '0194';
1378
        } /* rule: unknown
1379
         * sample:
1380
         *   - These recipients of your message have been processed by the mail server:
1381
         *   [email protected]; Failed; 5.1.1 (bad destination mailbox address)
1382
         */
1383 1
        elseif (preg_match('/bad.*(?:alias|account|recipient|address|email|mailbox|user)/i', $status_code)) {
1384
          $result['rule_cat'] = 'unknown';
1385
          $result['rule_no'] = '02441';
1386
        } /* rule: unknown
1387
         * sample:
1388
         *   - These recipients of your message have been processed by the mail server:
1389
         *   [email protected]; Failed; 5.1.1 (bad destination mailbox address)
1390
         */
1391 1
        elseif (preg_match('/bad.*(?:alias|account|recipient|address|email|mailbox|user)/i', $dsn_msg)) {
1392 1
          $result['rule_cat'] = 'unknown';
1393 1
          $result['rule_no'] = '0244';
1394
        } /* rule: full
1395
         * sample 1:
1396
         *   This Message was undeliverable due to the following reason:
1397
         *   The user(s) account is temporarily over quota.
1398
         *   <[email protected]>
1399
         * sample 2:
1400
         *   Recipient address: [email protected]
1401
         *   Reason: Over quota
1402
         */
1403 1
        elseif (preg_match('/over.*quota/i', $dsn_msg)) {
1404
          $result['rule_cat'] = 'full';
1405
          $result['rule_no'] = '0131';
1406
        } /* rule: full
1407
         * sample:
1408
         *   Sorry the recipient quota limit is exceeded.
1409
         *   This message is returned as an error.
1410
         */
1411 1
        elseif (preg_match('/quota.*exceeded/i', $dsn_msg)) {
1412
          $result['rule_cat'] = 'full';
1413
          $result['rule_no'] = '0150';
1414
        } /* rule: full
1415
         * sample:
1416
         *   The user to whom this message was addressed has exceeded the allowed mailbox
1417
         *   quota. Please resend the message at a later time.
1418
         */
1419 1
        elseif (preg_match("/exceed.*\n?.*quota/i", $dsn_msg)) {
1420
          $result['rule_cat'] = 'full';
1421
          $result['rule_no'] = '0187';
1422
        } /* rule: full
1423
         * sample 1:
1424
         *   Failed to deliver to '<[email protected]>'
1425
         *   LOCAL module(account xxxxxx) reports:
1426
         *   account is full (quota exceeded)
1427
         * sample 2:
1428
         *   Error in fabiomod_sql_glob_init: no data source specified - database access disabled
1429
         *   [Fri Feb 17 23:29:38 PST 2006] full error for caltsmy:
1430
         *   that member's mailbox is full
1431
         *   550 5.0.0 <[email protected]>... Can't create output
1432
         */
1433 1
        elseif (preg_match('/(?:alias|account|recipient|address|email|mailbox|user).*full/i', $dsn_msg)) {
1434
          $result['rule_cat'] = 'full';
1435
          $result['rule_no'] = '0132';
1436
        } /* rule: full
1437
         * sample:
1438
         *   gaosong "(0), ErrMsg=Mailbox space not enough (space limit is 10240KB)
1439
         */
1440 1
        elseif (preg_match('/space.*not.*enough/i', $dsn_msg)) {
1441
          $result['rule_cat'] = 'full';
1442
          $result['rule_no'] = '0219';
1443
        } /* rule: defer
1444
         * sample 1:
1445
         *   ----- Transcript of session follows -----
1446
         *   [email protected]... Deferred: Connection refused by nomail.tpe.domain.com.
1447
         *   Message could not be delivered for 5 days
1448
         *   Message will be deleted from queue
1449
         * sample 2:
1450
         *   451 4.4.1 reply: read error from www.domain.com.
1451
         *   [email protected]... Deferred: Connection reset by www.domain.com.
1452
         */
1453 1
        elseif (preg_match('/Deferred.*Connection (?:refused|reset)/i', $dsn_msg)) {
1454
          $result['rule_cat'] = 'defer';
1455
          $result['rule_no'] = '0115';
1456
        } /* rule: dns_unknown
1457
         * sample:
1458
         *   ----- The following addresses had permanent fatal errors -----
1459
         *   Tan XXXX SSSS <[email protected]>
1460
         *   ----- Transcript of session follows -----
1461
         *   553 5.1.2 XXXX SSSS <[email protected]>... Invalid host name
1462
         */
1463 1
        elseif (preg_match('/Invalid host name/i', $dsn_msg)) {
1464
          $result['rule_cat'] = 'dns_unknown';
1465
          $result['rule_no'] = '0239';
1466
        } /* rule: dns_unknown
1467
         * sample:
1468
         *   ----- Transcript of session follows -----
1469
         *   [email protected]... Deferred: mail.domain.com.: No route to host
1470
         */
1471 1
        elseif (preg_match('/Deferred.*No route to host/i', $dsn_msg)) {
1472
          $result['rule_cat'] = 'dns_unknown';
1473
          $result['rule_no'] = '0240';
1474
        } /* rule: dns_unknown
1475
         * sample:
1476
         *   ----- Transcript of session follows -----
1477
         *   550 5.1.2 [email protected]... Host unknown (Name server: .: no data known)
1478
         */
1479 1
        elseif (preg_match('/Host unknown/i', $dsn_msg)) {
1480
          $result['rule_cat'] = 'dns_unknown';
1481
          $result['rule_no'] = '0140';
1482
        } /* rule: dns_unknown
1483
         * sample:
1484
         *   ----- Transcript of session follows -----
1485
         *   451 HOTMAIL.com.tw: Name server timeout
1486
         *   Message could not be delivered for 5 days
1487
         *   Message will be deleted from queue
1488
         */
1489 1
        elseif (preg_match('/Name server timeout/i', $dsn_msg)) {
1490
          $result['rule_cat'] = 'dns_unknown';
1491
          $result['rule_no'] = '0118';
1492
        } /* rule: dns_unknown
1493
         * sample:
1494
         *   ----- Transcript of session follows -----
1495
         *   [email protected]... Deferred: Connection timed out with hkfight.com.
1496
         *   Message could not be delivered for 5 days
1497
         *   Message will be deleted from queue
1498
         */
1499 1
        elseif (preg_match('/Deferred.*Connection.*tim(?:e|ed).*out/i', $dsn_msg)) {
1500
          $result['rule_cat'] = 'dns_unknown';
1501
          $result['rule_no'] = '0119';
1502
        } /* rule: dns_unknown
1503
         * sample:
1504
         *   ----- Transcript of session follows -----
1505
         *   [email protected]... Deferred: Name server: domain.com.: host name lookup failure
1506
         */
1507 1
        elseif (preg_match('/Deferred.*host name lookup failure/i', $dsn_msg)) {
1508
          $result['rule_cat'] = 'dns_unknown';
1509
          $result['rule_no'] = '0121';
1510
        } /* rule: dns_loop
1511
         * sample:
1512
         *   ----- Transcript of session follows -----
1513
         *   554 5.0.0 MX list for znet.ws. points back to mail01.domain.com
1514
         *   554 5.3.5 Local configuration error
1515
         */
1516 1
        elseif (preg_match('/MX list.*point.*back/i', $dsn_msg)) {
1517
          $result['rule_cat'] = 'dns_loop';
1518
          $result['rule_no'] = '0199';
1519
        } /* rule: internal_error
1520
         * sample:
1521
         *   ----- Transcript of session follows -----
1522
         *   451 4.0.0 I/O error
1523
         */
1524 1
        elseif (preg_match("/I\/O error/i", $dsn_msg)) {
1525
          $result['rule_cat'] = 'internal_error';
1526
          $result['rule_no'] = '0120';
1527
        } /* rule: internal_error
1528
         * sample:
1529
         *   Failed to deliver to '[email protected]'
1530
         *   SMTP module(domain domain.com) reports:
1531
         *   connection with mx1.mail.domain.com is broken
1532
         */
1533 1
        elseif (preg_match('/connection.*broken/i', $dsn_msg)) {
1534
          $result['rule_cat'] = 'internal_error';
1535
          $result['rule_no'] = '0231';
1536
        } /* rule: other
1537
         * sample:
1538
         *   Delivery to the following recipients failed.
1539
         *   [email protected]
1540
         */
1541 1
        elseif (preg_match("/Delivery to the following recipients failed.*\n.*\n.*" . $result['email'] . '/i', $dsn_msg)) {
1542
          $result['rule_cat'] = 'other';
1543
          $result['rule_no'] = '0176';
1544
        }
1545
1546
        // Followings are wind-up rule: must be the last one
1547
        //   many other rules msg end up with "550 5.1.1 ... User unknown"
1548
        //   many other rules msg end up with "554 5.0.0 Service unavailable"
1549
1550
        /* rule: unknown
1551
         * sample 1:
1552
         *   ----- The following addresses had permanent fatal errors -----
1553
         *   <[email protected]>
1554
         *   (reason: User unknown)
1555
         * sample 2:
1556
         *   550 5.1.1 [email protected]... User unknown
1557
         */
1558 1
        elseif (preg_match('/(?:User unknown|Unknown user)/i', $dsn_msg)) {
1559
          $result['rule_cat'] = 'unknown';
1560
          $result['rule_no'] = '0193';
1561
        } /* rule: unknown
1562
         * sample:
1563
         *   554 5.0.0 Service unavailable
1564
         */
1565 1
        elseif (preg_match('/Service unavailable/i', $dsn_msg)) {
1566 1
          $result['rule_cat'] = 'unknown';
1567 1
          $result['rule_no'] = '0214';
1568
        }
1569 2
        break;
1570
1571
      case 'delayed':
1572
        $result['rule_cat'] = 'delayed';
1573
        $result['rule_no'] = '0110';
1574
        break;
1575
1576
      case 'delivered':
1577
      case 'relayed':
1578
      case 'expanded': // unhandled cases
1579
        break;
1580
1581
      default:
1582
        break;
1583
    }
1584
  }
1585
1586 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...
1587 2
  if ($result['rule_no'] == '0000') {
1588 1
    if ($debug_mode) {
1589
      echo 'email: ' . $result['email'] . $bmh_newline;
1590
      echo 'Action: ' . $action . $bmh_newline;
1591
      echo 'Status: ' . $status_code . $bmh_newline;
1592
      echo 'Diagnostic-Code: ' . $diag_code . $bmh_newline;
1593
      echo "DSN Message:<br />\n" . $dsn_msg . $bmh_newline;
1594 1
      echo $bmh_newline;
1595
    }
1596 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...
1597 2
    if ($result['bounce_type'] === false) {
1598 2
      $result['bounce_type'] = $rule_categories[$result['rule_cat']]['bounce_type'];
1599 2
      $result['remove'] = $rule_categories[$result['rule_cat']]['remove'];
1600
    }
1601
  }
1602
1603 2
  return $result;
1604
}
1605