Tools for Cleaning an email list

Supposing I have a forum that was spammed or maybe another list that people joined over the years. I don’t really want to sign up for a service as I have a good way to email my lists. I just need a good way to identify the bad ones. Are there maybe some PHP solutions that will follow the reply to address and identify the obvious bad email addresses that bounced after a couple of attempts or similar?

This will find out of an MX recored exists

public function isDomain($email) {
    // split email address into username and domain.
    list($userName, $mailDomain) = split("@", $email);
    if (!checkdnsrr($mailDomain, "MX")) {
        return $mailDomain;
    }
    return FALSE;
} // public function isDomain($email)

Wikipedia: MX record

Thank you very much. I am going to get this reviewed by our dev team. Sounds simple enough.

The code you provided will just check for invalid email addresses (invalid due to domain not exists, etc). However, it does not provide clue about other invalid mailbox types.

like mailbox unavailable, mailbox quota full, etc. Probably, telnetting to SMTP ports to the mail server in question will properly respond with the status.

This is correct. It’s a partial solution that helps cut down on badly addressed mail. I use it to check the input and it helps to pick up typos. If a user of a contact form gives a bad email address and never receives a rely, he does not blame himself but the contact form – he figures he was ignored.

However, it does not provide clue about other invalid mailbox types like mailbox unavailable, mailbox quota full, etc. Probably, telnetting to SMTP ports to the mail server in question will properly respond with the status.

By using mail() [but not imap_mail()] php sets the correct bounce address [Return-path:] Here is the one from the SitePoint forum alert mail:

Return-path: <bounces+12300-fa47-user=myDomain.info@email.sitepoint.com>

where “user=myDomain.info” is my email address. By setting up a catch-all sitePoint gets the desired feedback.