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:
- 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
The difficult part is the last bit - since just because you receive a bounce from an email address, it doesnt mean the address is bad. Some addresses may have intermittant problems, you'll get "out of office" autoresponders to that address too, there's many different types of bounces to recognise and finally not all bounces you get back follow a standard format!
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