Re: unavailable email question
am 20.12.2007 14:07:07 von Toby A InksterBob Bedford wrote:
> We tought about using a special email (like newsletter@ourdomain.com)
> then using a PHP script to catch the returning email and catch some text
> on them and decide if we remove the address from our mailing list or
> not. It's possible with PHP ? It is the best solution ?
ourdomain.com is a real domain name owned by Eurobox Ltd, St Petersburg.
If you're not affiliated with that company, then you should probably stop
including their e-mail address in your posts -- they might not appreciate
it. Domains example.org, example.com and example.net are registered
specifically for the purpose of providing examples -- use them.
Now, on to your question: include whatever From address you like. The
trick is in the "Return-Path" header. What you do is take the user's e-
mail address and massage it a bit to add a return path header to your
message:
$my_domain = 'example.com';
$their_address = 'fred@example.org';
$return_path = 'newsletter+'
. str_replace('@', '=', $their_address)
. '@' . $my_domain;
$headers .= "Return-Path: $return_path";
Now, if fred@example.org's mail bounces, the error message should get sent
to "newsletter+fred=example.org@example.com". Most mail servers will by
default treat this as an alias for "newsletter@example.com". If not, this
feature can normally be enabled using the mail server's "VERP" setting.
Now you can write a script to periodically scan through the incoming mail
for newsletter@example.com, pick out "To" addresses that match the regular
expression "/^newsletter\+/i" and then transform them to determine the
problem e-mail account:
$to_addr = 'newsletter+fred=example.org@example.com';
if (preg_match('/^newsletter\+/i'))
{
$to_addr = preg_replace('/^newsletter\+/i', '', $to_addr);
list($to_addr, $dummy) = explode('@', $to_addr);
$at_pos = strrpos($to_addr, '=');
$to_addr[$at_pos] = '@';
echo "Bounce from $to_addr\n";
}
Now you might not want to instantly unsubscribe this person from the
mailing list. Sometimes e-mail addresses temporarily start to bounce, e.g.
the user's mailbox has gone overquota, but starts working again once they
delete a few large attachments.
An idea might be to simply record all bounces into your database so that
you can unsubscribe (or perhaps, "put on hold") contacts who have, say,
bounced more than four times in the last two months (the exact criteria
are up to you!). If they are important customers you could phone them up
to ask them to confirm which is the best e-mail address for you to send
the newsletter to.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 12 days, 23:15.]
Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/