Email marketing is still one of the most efficient ways to reach your customer, leads and site followers. If your mailing list becomes older and hasn’t been used for some time, there is serious chance that some of the email addresses aren’t valid anymore.
Why do you need to verify these email addresses?
Some people would say, why should I care and there are people sending out their mailings to these invalid email addresses many times.
There is huge risk that your mail servers will get on a blacklist if you do this. A receiving mail server might blacklist your own server because you deliver your mail to a mailbox that doesn’t exists anymore. Maybe you use a professional transactional SMTP provider (Mandrill, Mailgun, etc.) like I do. These services will put these “bad” email addresses on a blacklist and if there are too much of them they will disable your account.
You see it’s much better to verify your email address first.
Different ways to validate or verify your email addresses
There are many ways how you can do that, some of the are simple and free and others are more complex and require some programming skills.
Regular expression check
The most simple way is to use regular expression pattern/check against all your email addresses. Actually you should do that at the moment that you build a list. Don’t accept a email subscription from an invalid email address
Checking MX records
This basic test is also very easy, just check the DNS from each domain that a MX record exists. If the domain name doesn’t exists or is not configured, the MX record is missing, too.
Simulate an email delivery
Establish a SMTP connection and check on the target server if the email address still exists and accepts emails. This is almost the same as sending a real email message. I found these great PHP class to verify my email addresses this way (more on that later).
Verify your email addresses with Mailgun
Mailgun offers a service you can use to check every email address before your really use it. Their API/service is free to use and only requires a Mailgun account. I used them for batches of ~1000 email addresses and didn’t got a warning for abusing. On Web Development Blog is a tutorial on how to validate an email address with the Mailboxlayer API.
Verify your emails online
There are also many websites which offer this feature online. Most of them allow the email verification only for a single address. This service is very good and doesn’t show many false results and I use them from time to time to check a single address where the email was bounced. The offer also premium plans and an API system to check multiple email addresses.
How I verified 6000+ email addresses right from my Laptop
Even if you use a SMTP validation script, there is a chance the sending IP address becomes on a black list. So be careful if your list is huge!
Last time I need to check a list where I know that 25% of the email addresses has bounced while a customer has send his email campaigns. I use my laptop to check them using the SMTP connection from my own ISP which I never use for email :)
Note, I used my laptop with a LAMP installation to run the following code.
Checking 6000+ email addresses will take some time, so it’s better to check smaller packages by running a CRON job. First import your email addresses into a MySQL database. Create a simple table structure (ID, email, status) and import all email address using the .csv import feature from phpMyAdmin.
I’ve used the following script to check all the email addresses in packages of 25.
The required PHP class script (smtp-validate-email.php) is the one I’ve mentioned before. Execute the PHP script every ~5 minutes by using a CRON job.