3

Some people have subscribed to my blog by entering their email address.

But some of the email addresses don’t exist.

How can I know if these email addresses are valid when I send an email to these email addresses?

1

4 Answers 4

9

Send them a confirmation mail with a link, and activate the subscription only if they click that link.

2
  • 1
    Truly an innovative technique!
    – JAL
    Commented Nov 21, 2010 at 19:00
  • This is the only solution that actually works. I always recommend verifying an email in this manner before subscribing someone to a list or accepting an email for account creation or entering it into any database that will have the potential of generating automated emails. Best-case scenario of not doing it is bounces and bad data, worst-case, spam complaints and loss of the reputation of your domain and/or mailservers and possible termination of your mail provider or your hosting provider if you have your own mailserver.
    – cazort
    Commented Oct 27, 2021 at 15:56
2

As far as I know, you can't. You'll know that the email is not valid when you fail to deliver the email, whether it's because the domain doesn't exists or the account doesn't exists on that domain.

If you want to make sure only real accounts are used to subscribe, send a confirmation email where the user clicks a link to validate his account (like casablanca says here).

2

You'll never be 100% sure that a provided email address really exists.

One way would be to use the SMTP VRFY command to instruct the destination mail relay to confirm the recipient. But many servers don't provide this feature. It also requires direct SMTP communication to do the check.

Even when the destination server doesn't refuse your recipient, the recipient may not exist, as some servers accept all incoming emails and bounce them back at a later stage.

You may implement the following commands (or use one of the many PHP scriplets that do it for you):

HELO <your server name>
MAIL FROM: <>
RCPT TO: <[email protected]>
QUIT
1

You can do an MX record lookup with:

$result = getmxrr($hostname, $mxHosts);
if(count($mxHosts) < 1){
   //no MX records found
}

This will prevent your users from using the '[email protected]'-type of input. See the manual page on php.net: http://www.php.net/manual/en/function.getmxrr.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.