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?

Gumbo
  • 643,351
  • 109
  • 780
  • 844
xRobot
  • 25,579
  • 69
  • 184
  • 304
  • What's the difference to this previous question of yours: [How to know if a email address is invalid?](http://stackoverflow.com/questions/4235497/how-to-know-if-a-email-address-is-invalid) and also is this the same "blog" as in [How to send 100.000 emails weekly ??](http://stackoverflow.com/questions/3905734/how-to-send-100-000-emails-weekly) – mario Nov 21 '10 at 18:50

4 Answers4

9

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

casablanca
  • 69,683
  • 7
  • 133
  • 150
  • 1
    Truly an innovative technique! – JAL Nov 21 '10 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 Oct 27 '21 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).

Community
  • 1
  • 1
Pablo Venturino
  • 5,208
  • 5
  • 33
  • 41
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: <destination@to.check>
QUIT
icanhasserver
  • 1,054
  • 10
  • 11
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 'jdjshjk@fdhjk.dff'-type of input. See the manual page on php.net: http://www.php.net/manual/en/function.getmxrr.php

Yeroon
  • 3,223
  • 2
  • 22
  • 29