amit
amit

Reputation: 127

PHP email verification

I've used SMTP commands for "Checking/Verifying" the email address (whether it actually exists or not). But the problem is that it sometimes accepts email as a valid email address and sometimes does not.

Is it a SMTP server's limitation (for security purpose) on verifying email? If so, then what alternative approaches do I have?

Upvotes: 3

Views: 1993

Answers (2)

Justin Helmig
Justin Helmig

Reputation: 66

As noted above, most email servers shut down the VRFY command since it is prone to email harvesting from spammers.

There are a few options for verifying email addresses

1) Use an email verification link. This can cause a drop in conversion rate as potentially get your email sender (either you or an ESP who will complain at you) in trouble if you are sending too many verification emails that bounce. If you have any deliverability issues, the links will end up in the spam/bulk folder and never get clicked. I am not a big fan of this approach if you care about conversion and/or support tickets. I did some research on this a while back and wrote a blog entry if you are interested: http://blog.strikeiron.com/bid/54483/Email-Verification-Links-Kill-Your-Conversion-Rate

2) Use a paid tool. These come in 3 flavors a) real-time API - there are companies (full disclosure, mine is one of the companies in this space) that offer paid solutions are able to verify emails in realtime with high (>95%) accuracy. b) database lookup vendors - this is another paid option where the collected email is compared against a database. Generally less expensive but not as accurate as real-time c) tools for your PC - avoid this. They are not accurate and will get your IP address blacklisted.

3) Do a quick check (regex, check for a MX server, etc) and accept ambiguous emails as valid. Depending on your volume and audience, this might be a good option.

Hope this helps.

Justin

Upvotes: 2

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167162

Best way is to get the confirmation from the user. Create a random number with the user's name, using mt_rand() and store it in the DB while creation. Keep a flag activated to 0.

Send out a mail with the activation key, the random number stored in the DB. Small possible way would be this:

<?php
    $random = mt_rand(1, 1000);
    $random = $username . $random;
    # Store the $random in the DB.

    # Now send a mail
    mail($userEmail, "Confirm", "Your Unique ID is $random");
?>

Upvotes: 1

Related Questions