简体   繁体   中英

check to email is exists or no

I want to check entered email address before registering, I found some solutions in SF but these solutions says we should check MX or SMTP port, but we have some fake emails like :

111111@gmail.com
some.email.address@gmail.com
and ...

when I check the gmail.com domain this domain have MX record and there is no problem but this emails are fake !

Is there any way to ping email address with php?

您唯一可以做的就是发送确认电子邮件,并要求用户单击链接或提供您在此电子邮件中发送的代码。

You CAN check for the existence without sending a mail.

After you get the MX record, you can use SMTP protocol to communicate with the server directly.

For example: (the lines starting with > means input. )

> telnet gmail-smtp-in.l.google.com 25
Trying 74.125.129.26...
Connected to gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP pa10si7038694pbc.108 - gsmtp

> HELO
250 mx.google.com at your service

> MAIL FROM: <test@test.com>
250 2.1.0 OK rw3si4189390pab.9 - gsmtp

> RCPT TO: <notexists___@gmail.com>
550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 rw3si4189390pab.9 - gsmtp

If you replace notexists___@gmail.com with 111111@gmail.com :

> RCPT TO: <111111@gmail.com>
250 2.1.5 OK il2si7046221pbc.91 - gsmtp

In PHP, you can use socket functions to do things above.

NOTICE: This approach may not work on some SMTP servers.

The only way i know to check email-addresses is through sending an email to them.

Why do you need to check the e-mail address beforehands? You could just send them an "activation link" what also prooves not only the existance but the person behind the address.

You can send a confirmation mail, so that you know that address works. If that is not an option, you can check of the domain actually exists. That way you disregard something@non_existing_domain.com

// or use ANY or for other see above link
if (checkdnsrr('non_existing_domain.com', 'A')){ echo 'Domain exists'; }
else { echo 'Domain does not exist'; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM