using swift to detect bouncebacks
Moderators: Chris Corbyn, General Moderators
using swift to detect bouncebacks
In the past, I've had a server get blacklisted because I blindly sent out mail frequently to my entire member list, regardless if the email address was good or invalid or anything.
I'd like to set up some sort of thing when I batch mail to detect the emails that immediately get rejected and flag them in my database. Is this possible using only swift.. or perhaps a swift plugin?
If not, I can do it manually by setting the return path and checking the mailbox all the time, but It'd be nice to do it in the application.
I'd like to set up some sort of thing when I batch mail to detect the emails that immediately get rejected and flag them in my database. Is this possible using only swift.. or perhaps a swift plugin?
If not, I can do it manually by setting the return path and checking the mailbox all the time, but It'd be nice to do it in the application.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
scottay no like reading the documentation?
Although I fail to see why you would get blacklisted for sending emails to non-existent addresses.
http://swiftmailer.org/wikidocs/v3/send ... recipients
http://swiftmailer.org/wikidocs/v3/send ... recipients
I was reading around in the tips for not being flagged as spam 
Thanks for that link. Looks really useful.
Thanks for that link. Looks really useful.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
This is tricky to do..something I'm looking into at the moment..that link above doesnt really apply because it only deals with invalid/malformed addresses that are rejected immediately by your local smtp server. The addresses you have to worry about are the ones that are sent out by your server but then bounced back by remote servers. I believe repeat sending to these bad addresses *can* get you blacklisted as it makes you look like a spammer (who will never bother cleaning their list).
So to really keep your list clean, you need to:
It can be fairly simple to do the processing manually as you said, this just becomes difficult if you have a large volume which is when you need an automated system.
I found these two articles rather useful to summarise the issue of bounces:
http://www.clickz.com/showPage.html?page=3439641
http://www.clickz.com/showPage.html?page=3464041
I'm currently working on a way to automate solving this, as I'm not aware of an open-source solution to do it. Note that it can't be a plugin to Swift as most of the work has to be done at some point in the future after sending your mails - probably by a cron job scheduled to run automatically on a regular basis.
I'm considering using the library from http://www.boogietools.com/ (which requires paying for) - you feed this the raw text of an email and it tells you whether it's a bounce, what address it bounced from etc. This doesnt do all the work however as I still need to retreive the mails from the return-path mailbox and make the decision as to when to mark an address as bad.
I'm in the early stages, so if anyone has any experience or suggestions as to what to do, or knows of a pre-existing alternative, then please let us all know!
Cheers,
-- A
So to really keep your list clean, you need to:
- process getFailedRecipients() as linked to above - this returns all email addresses rejected by your local server because e.g. they aren't proper e-mail addresses.
- set up the return path and a mailbox to catch bounces
- process the bounces to determine which emails to mark as bad
It can be fairly simple to do the processing manually as you said, this just becomes difficult if you have a large volume which is when you need an automated system.
I found these two articles rather useful to summarise the issue of bounces:
http://www.clickz.com/showPage.html?page=3439641
http://www.clickz.com/showPage.html?page=3464041
I'm currently working on a way to automate solving this, as I'm not aware of an open-source solution to do it. Note that it can't be a plugin to Swift as most of the work has to be done at some point in the future after sending your mails - probably by a cron job scheduled to run automatically on a regular basis.
I'm considering using the library from http://www.boogietools.com/ (which requires paying for) - you feed this the raw text of an email and it tells you whether it's a bounce, what address it bounced from etc. This doesnt do all the work however as I still need to retreive the mails from the return-path mailbox and make the decision as to when to mark an address as bad.
I'm in the early stages, so if anyone has any experience or suggestions as to what to do, or knows of a pre-existing alternative, then please let us all know!
Cheers,
-- A
I'm thinking the only way to do it is manually.
Won't be too bad to process if an administration form is built to flag a field in the database. Just type in the email address and submit. Of course this tool would have to check for duplicate emails being entered within a relatively short amount of time, and that the email exists in the mailing list.
A minor pain, but worthy if you want to keep your list "clean".
Won't be too bad to process if an administration form is built to flag a field in the database. Just type in the email address and submit. Of course this tool would have to check for duplicate emails being entered within a relatively short amount of time, and that the email exists in the mailing list.
A minor pain, but worthy if you want to keep your list "clean".
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
yup - a semi-automated system like that form that makes it as easy as pasting in each email address would be the most efficient way if you only have a few bad addresses.. you could even make a form that lets you paste a bunch of addresses into a textbox and process them all at once for you!
i'm working on a system that's sending out 10s of 000s of mails a week and have a mailbox full of 000s of bounces, autoresponders and other junk..so i've got to work out a way to do it like the big boys!
i'm working on a system that's sending out 10s of 000s of mails a week and have a mailbox full of 000s of bounces, autoresponders and other junk..so i've got to work out a way to do it like the big boys!
Good luck with that. Do post your solution if you arrive at one. 
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Swift is about sending mail, which is certainly very cool, but it isn't a complete mailing list suite.
You could use PHP's IMAP functions to check a bounce mailbox, perform a regex match for "delivery failed" or whatever the cool kids are saying these days, then remove the original TO address from your list.
You could use PHP's IMAP functions to check a bounce mailbox, perform a regex match for "delivery failed" or whatever the cool kids are saying these days, then remove the original TO address from your list.
-
Flurrywinde
- Forum Newbie
- Posts: 18
- Joined: Mon Feb 04, 2008 3:30 pm
Re: using swift to detect bouncebacks
Use the code found here: http://www.anti-spam-man.com/php_bouncehandler/v4/ . It's a class that, when fed a bounce e-mail, extracts information about the bounce, like the e-mail address in question and the nature of the bounce (i.e. transient, permanent, etc.).
What I did was take this code and make it into a PHP file that accepts input from stdin. Then, I pipe all incoming e-mail to the return-path address to this file, which automatically extracts the bounce information and puts it into a database.
I plan to write code that will process these database entries, either semi-automatically or automatically. If you beat me to it, hand it over!
Even as is, however, having the bad e-mail addresses in a database makes things a lot easier.
Here's the meat of my file: (Pretty much the only thing I removed is the code for connecting to my database and my e-mail address.)
What I did was take this code and make it into a PHP file that accepts input from stdin. Then, I pipe all incoming e-mail to the return-path address to this file, which automatically extracts the bounce information and puts it into a database.
I plan to write code that will process these database entries, either semi-automatically or automatically. If you beat me to it, hand it over!
Here's the meat of my file: (Pretty much the only thing I removed is the code for connecting to my database and my e-mail address.)
Code: Select all
require_once("bounce_driver.class.php");
// read e-mail from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
// Scan e-mail for bounce data
$bounceInfoArray = Bouncehandler::get_the_facts($email);
// If it's a bounce, record the recipient
// Otherwise, redirect the e-mail for user perusal
//
foreach($bounceInfoArray as $the){
switch($the['action']){
case 'failed':
case 'autoreply':
case 'transient':
$bad_recipient = $the['recipient'];
$bounce_action = $the['action'];
$time = time();
$sql = "INSERT INTO
bounce(bad_recipient,bounce_action,time,email) VALUES('$bad_recipient','$bounce_action',$time,'".mysql_real_escape_string($email)."')";
mysql_query($sql, $dbh);
break;
default:
// Extract the head and body of the e-mail
$bounce = BounceHandler::init_bouncehandler($email, 'string');
list($head, $body) = preg_split("/\r\n\r\n/", $bounce, 2);
$head_hash = BounceHandler::parse_head($head);
// Send e-mail in question to new recipient
$mail_result = mail('your email address here', $head_hash['Subject'], "The following e-mail was processed by the bounce manager:\n\n".$email);
}
}