forked from rbairwell/PHP-Bounce-Handler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.html
75 lines (67 loc) · 2.67 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<p>Quick and dirty bounce handler</p>
<p><strong>Usage</strong></p>
<blockquote><code>
require_once('bounce_driver.class.php');
$bouncehandler=new Bouncehandler();
$multiArray=$bouncehandler->get_the_facts(\$strEmail)
</code></blockquote>
<p>( $multiArray=$bouncehandler->get_the_facts(\$strEmail) can be replaced by $multiArray = $bouncehandler->parse_email($strEmail) )</p>
<p>Returns a multi-dimensional associative array of bounced recipient addresses and their SMTP status codes (if available) - see
<code>print_r(\$multiArray);</code></p>
<p>Will return recipient's email address, the RFC1893 error code, and the action. Action can be one of the following:<dl>
<dt>transient</dt><dd>Temporary problem</dd>
<dt>failed</dt><dd>Permanent problem</dd>
<dt>autoresponse</dt><dd>Vacation auto-response/auto-responder<dd>
<dt>""</dt><dd>Empty string - not classified</dd>
</dl></p>
You could dereference the \$multiArray in a 'for loop', for example...</P>
<pre>
foreach($multiArray as $the){
switch($the['action']){
case 'failed':
//do something
kill_him($the['recipient']);
break;
case 'transient':
//do something else
$num_attempts = delivery_attempts($the['recipient']);
if($num_attempts > 10){
kill_him($the['recipient']);
}
else{
insert_into_queue($the['recipient'], ($num_attempts+1));
}
break;
case 'autoresponse':
//do something different
postpone($the['recipient'], '7 days');
break;
default:
//don't do anything
break;
}
}
</pre>
Or, if it is an FBL, you could use the class variables to access the
data (Unlike Multipart-reports, FBL's report only one bounce)
You could also use them if the output array has only one index:
<pre>
if($bouncehandler->type == 'fbl'
or count($bouncehandler->output) == 1)
{
echo $bouncehandler->action;
echo $bouncehandler->status;
echo $bouncehandler->recipient;
echo $bouncehandler->feedback_type;
}
</pre>
These class variables are safe for all bounce types:
<ul>
<li>$bouncehandler->type</li>
<li>$bouncehandler->subject</li>
<li>$bouncehandler->web_beacon_1</li>
<li>$bouncehandler->web_beacon_2</li>
<li>$bouncehandler->x_header_beacon_1</li>
<li>$bouncehandler->x_header_beacon_2</li>
</ul>
<p>That's all you need to know, but if you want to get more complicated you can. Most methods are public. See source code.</p>