开发者

How to know if an email address exist through PHP?

Some people have subscribed to my blog by enterin开发者_运维问答g 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?


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


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).


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜