-
Notifications
You must be signed in to change notification settings - Fork 6
/
ch040_bounce-management.xhtml
208 lines (208 loc) · 11.7 KB
/
ch040_bounce-management.xhtml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title/></head><body><h1>Bounce Management
</h1>
<h2>Introduction to bounce management
</h2>
<p>Whenever an email is sent via the internet, regardless of the email software used, the email is transmitted by an MTA (Mail Transport Agent).  In most cases the MTA is the internet provider’s SMTP mail server, sending to the MTA of the email’s recipient, through intermediary MTAs.
</p>
<p>If the email cannot be delivered to its recipient, the last MTA that tried to transmit the email generates an error email, called a bounce message, which is sent back to the sender’s email.
</p>
<p>Usually, this bounce message contains a specific error code that explains why your email could not be delivered to its recipient.
</p>
<p>phpList implements bounce management which handles these bounce messages, and provides automatic actions depending on the error code, like removing an incorrect email address. 
</p>
<h2>Setting up basic bounce management
</h2>
<p>Basic bounce management counts bounces and unconfirms a user after a given number of consecutive bounces. 
</p>
<h3>Setting your bounce address 
</h3>
<p>In order to use bounce management, you need to provide an email address where the bounce messages are sent to (e.g.: [email protected]). This email address is usually called the Return Path. Note that this email address will only be added to the email headers, and will not be shown to your users.
</p>
<div>Once you have set up your return path email address, you may edit the config.php by adding the following:
</div>
<p><strong>$message_envelope = '[email protected];</strong>
</p>
<p>By default this setting is commented out (it has a # in front so will not be actioned). 
</p>
<p><img src="/phplist/_edit/static/bounce_config_1.png" alt=""/></p>
<p>You will need to uncomment it (remove the hash) and change the email to reflect your new bounce email.
</p>
<p><img src="static/bounce_config_2.png" alt=""/> 
</p>
<h3>pop or mbox 
</h3>
<p>phpList can fetch emails from the bounce mailbox via two protocols, mbox protocol where mails are accessed directly within a folder on the server, and pop3 protocol where mails are downloaded just like a mail client program would do it. The latter one is usually the simplest option, especially if you don’t host your phpList setup yourself.
</p>
<p>You can specify which procotol to use in config.php with the following:
</p>
<p><strong># This can be 'pop' or 'mbox'</strong>
</p>
<p><strong>$bounce_protocol = 'pop';</strong>
</p>
<p>When accessing the bounce mailbox via mbox protocol, we need to tell phpList where the mbox files are. Edit config.php and add the following:
</p>
<p><strong># when the protocol is mbox specify this one</strong>
</p>
<p><strong># it needs to be a local file in mbox format, accessible to your webserver user</strong>
</p>
<p><strong>$bounce_mailbox = '/var/spool/mail/listbounces';</strong>
</p>
<p>When accessing the bounce mailbox via pop3 protocol, we need to tell phpList which server provides the emails, and the username and password for the mailbox in config.php like this:
</p>
<p><strong># when the protocol is pop, specify these three</strong>
</p>
<p><strong>$bounce_mailbox_host = 'pop.example.com';</strong>
</p>
<p><strong>$bounce_mailbox_user = 'popuser';</strong>
</p>
<p><strong>$bounce_mailbox_password = 'password';</strong>
</p>
<p>Additionally, you might want to set the default pop3 port and encryption with the following line (standard config):
</p>
<p><strong>$bounce_mailbox_port = "110/pop3/notls";</strong>
</p>
<p>Or enabling ssl on port 995 without verifying certificate common name of the certificate:
</p>
<p><strong>$bounce_mailbox_port = "995/pop3/novalidate-cert"</strong>
</p>
<h3>Setting up mailbox purge 
</h3>
<p>Unless you’re doing some tests, you would want to delete bounce messages once they are fetched, so they won’t be counted twice:
</p>
<p><strong>$bounce_mailbox_purge = 1;</strong>
</p>
<p>You may also want to delete messages from the mailbox that could not be processed because they do not match a user in the system. Messages are still downloaded into phpList, so it’s safe to delete them from the mailbox.
</p>
<p><strong>$bounce_mailbox_purge_unprocessed = 1;</strong>
</p>
<p>You can define how many bounces in a row it needs for a user to be marked unconfirmed.
</p>
<p>Be aware that deleting processed bounce messages from phpList with advanced bounce rules will disable this functionality.
</p>
<p><strong> $bounce_unsubscribe_threshold = 5</strong>
</p>
<h2>Downloading and processing bounces 
</h2>
<p>Downloading and processing bounces can be handled in the user interface under <strong>System</strong> > <strong>Process Bounces</strong>.
</p>
<p>You may also setup a cron task to download and process bounces on a regular basis, see the chapter about cron tasks.
</p>
<p>In that case, you might want to disable the Process Bounces menu entry by adding the following:
</p>
<p><strong>define ("MANUALLY_PROCESS_BOUNCES",0);</strong>
</p>
<p><strong>define('BLACKLIST_EMAIL_ON_BOUNCE', 1</strong>);
</p>
<h2>Advanced bounce management
</h2>
<p>Advanced bounce management enables the automatic performance of various actions depending on the kind of bounce error code that is returned by the MTA.
</p>
<p>To enable it just add the following in config.php
</p>
<p><strong>define('USE_ADVANCED_BOUNCEHANDLING',1);</strong>
</p>
<p>Once this is set up, you may proceed in the phpList interface to <strong>System </strong>> <strong>Manage Bounces</strong> > <strong>List Bounces Rules</strong>
</p>
<p><img src="static/bounce_config_3.png" alt=""/> 
</p>
<p>From there you may create new bounce rules, based on regular expressions that will trigger phpList actions.
</p>
<p>Regular expressions are sequences of characters that match a search pattern. While this manual won’t explain the use of regular expressions, we will analyse the examples given here.
</p>
<p>Bounce emails generally contain a header and a mail body that may, depending on the MTA that sent the email, give a reason why the initial email could not reach its recipient.
</p>
<p>An example bounce email could look like the following:
</p>
<p><strong>Final-Recipient: rfc822; [email protected]</strong>
</p>
<p><strong>Original-Recipient: rfc822;[email protected]</strong>
</p>
<p><strong>Action: failed</strong>
</p>
<p><strong>Status: 5.2.1</strong>
</p>
<p><strong>Remote-MTA: dns; mx1.example.com</strong>
</p>
<p><strong>Diagnostic-Code: smtp; 550 5.2.1 This mailbox has been blocked due to</strong>
</p>
<p><strong>inactivity (UserSearch)</strong>
</p>
<p>What we see here is the recipient’s MTA telling us that the user’s mailbox is blocked, probably because it’s not been used for a long while. There are some excellent articles about MTA responses on the internet. Every MTA programme has its own return messages. Also, you may have noticed that the return messages usually come with a 3 digit code, 5.2.2 in this example.
</p>
<p>This code is the error code corresponding to the return message, but some MTAs just give bogus codes, especially when they think your email is spam.
</p>
<p>Now let’s create our first bounce rule:
</p>
<p><img src="static/bounce_config_4.png" alt=""/><br/></p>
<p>The regular expression could be the exact sentence the MTA return message contained, in brackets.
</p>
<p>Now phpList provides multiple actions that can be triggered if a bounce email matches our regular expression:
</p>
<p>
</p>
<ul><li>Delete subscriber</li>
<li>Unconfirm subscriber</li>
<li>Blacklist subscriber</li>
<li>Blacklist email address</li>
<li>Delete subscriber and bounce</li>
<li>Unconfirm subscriber and delete bounce</li>
<li>Add subscriber to the do-not-send list and delete bounce</li>
<li>Add email address to the do-not-send list and delete bounce</li>
<li>Delete bounce.</li>
</ul><p>
</p>
<p>In our case, we can assume that our subscriber’s email address haven’t been used for a long while, and that it’s safe to unconfirm the subscriber.
</p>
<p>Now we have a choice between “unconfirm subscriber” and “unconfirm subscriber and delete bounce”. The only real difference between both options is that deleting the bounce message will also remove it from bounce statistics (using the BounceStatisticsPlugin).
</p>
<p>Once we finished our rule, we may add it and try it against our bounces.
</p>
<p>Back in phpList, we can check if our rule matches any of our actual bounces, by going to<strong> System </strong>> <strong>Manage Bounces</strong> > <strong>Check Current Bounce Rules</strong>.
</p>
<p>The system will then tell us how many bounces are caught by our rules.
</p>
<p>Now you may have a big list of bounces that aren't caught by the rule, and some of them are pretty similar to the rule.
</p>
<p>We may have multiple bounce messages that could say “account is disabled” or “This account has been disabled” which basically means the same as “mailbox has been blocked due to inactivity” of our first rule.
</p>
<p>Way may create two other rules to deal with these bounces, or improve our regular expression to match all these messages with the same rule.
</p>
<p>Regular expressions use the pipe symbol “|” as OR statement, meaning the following regular expression:
</p>
<p>(black|white) would match any text that has the words black or white in it.
</p>
<p>Now let’s improve our first rule by adding all our MTA return messages that basically mean the same thing:
</p>
<p><img src="/phplist/_edit/static/bounce_config_5.png" alt=""/></p>
<p>The actual regular expression I used here is:
</p>
<p>(account is disabled|This mailbox has been blocked due to inactivity|This account has been disabled|The email account that you tried to reach does not exist|This is a permanent error * local delivery failed)
</p>
<p>Note that the * is a wildcard token that means there can be up to zero characters between “This is a permanent error “ and “ local delivery failed”.
</p>
<p>This rule can now deal with any of these 5 return messages.
</p>
<p>Good starter rule set:
</p>
<p><img src="static/bounce_config_6.png" alt=""/><br/></p>
<h2>Rules to copy
</h2>
<p><strong>(Archived recipient.) </strong>Delete subscriber
</p>
<p><strong>(delivery error: dd This user doesn't have a yahoo.fr account|This user doesn't have a yahoo.fr account) </strong>Delete subscriber
</p>
<p><strong>(type=MX: Host not found) </strong>Delete subscriber. No mail records for the domain.
</p>
<p><strong>(sorry, no mailbox here by that name|Mailbox disabled|address not found in table|User mailbox is not local|mailbox not allowed|Mailbox syntax incorrect|RESOLVER\.ADR\.RecipNotFound) </strong>Delete subscriber and bounce. No ambiguity here, we can also delete the bounce message.
</p>
<p><strong>(account is disabled|This mailbox has been blocked due to inactivity|This account has been disabled|The email account that you tried to reach does not exist|This is a permanent error * local delivery failed) </strong>Delete subscriber and bounce. Same as above
</p>
<p><strong>(User unknown|Unknown user|Unknown address|No such recipient|No such user|The email account that you tried to reach is disabled|Recipient not found|Recipient unknown|Invalid recipient|Address unknown|Recipient address rejected) </strong>Delete subscriber and bounce. Same as above
</p>
<h2>Feedback
</h2>
<p>Discuss this chapter <a href="https://discuss.phplist.org/t/bounce-management-manual-chapter-feedback-and-discussion/231">here</a>.
</p></body></html>