0

How to Performs deep level SMTP verification on each email address, each email address will be verified for mailbox existence without sending actual emails on that address in PHP?

suppose i have 5 email address

abc@gmail.com
def@gmail.com (fake)
ghi@gmail.com
jkl@gmail.com (fake)
mno@gmail.com

from above list, i have 2 fake/Spam email-id, i want to filter email-id by real and fake/Spam emails without sending email?

  • 1
    Give better example. – Affan Pathan Oct 31 '17 at 09:18
  • 1
    Your question shows [no attempt](http://idownvotedbecau.se/noattempt/) of solving the problem. If you try, you may succeed. But if you do not, you will always fail. And if you did try, without sharing our efforts with others, they may duplicate your work instead of providing a working solution. – Filnor Oct 31 '17 at 09:19
  • 2
    Can't be done. To verify an email address actually exists you need to send an email to it and wait for a response. The response may not always be valid i.e. mailbox full or other tech issue. All php, and other languages, can do is check that the email address mets certain criteria. –  Oct 31 '17 at 09:19
  • @savshit you need to use any email validate API to verify the email address before sending mail – Zuber Surya Oct 31 '17 at 09:20
  • I add example what i mean to do with PHP. – Savshit Mavani Oct 31 '17 at 09:24
  • Adding to what @jeff said, this would pose a huge problem. If spam bots were able to identify every single gmail address like this, our inboxes would soon be filled with more spam than actual emails. – Berry M. Oct 31 '17 at 09:26
  • 3
    Even if you can tell existing from non-existing addresses, the fact that an address *exists* still doesn't mean any particular human will receive/see emails you send to it. That's yet another layer. If you want to ensure you can communicate with a particular human via email, the only way is to send them an email and have them click a link/type a confirmation code or some such feedback loop. – deceze Oct 31 '17 at 09:36
  • Use API's that provides details for email verified and you can mark your DB with valid/invalid e-mail and send mails accordingly. - [https://mailboxlayer.com/](https://mailboxlayer.com/ ) - [http://emailpie.com/](http://emailpie.com/) – Zuber Surya Oct 31 '17 at 09:40
  • @ZuberSurya It really depends on how those services work, because if they check with SMTP then they won't work properly (see my answer). – AStopher Oct 31 '17 at 12:10
  • @SavshitMavani Did my answer help you? If so, please accept it. – AStopher Nov 14 '17 at 19:39

1 Answers1

0

You can:

You should check with SMTP.

That means you have to connect to that email's SMTP server.

After connecting to the SMTP server you should send these commands:

HELO somehostname.com MAIL FROM: RCPT TO: If you get ": Relay access denied" that means this email in invalid.

There is a simple PHP class. You can use it:

http://www.phpclasses.org/package/6650-PHP-Check-if-an-e-mail-is-valid-using-SMTP.html

...but it isn't advisable:

This is technically true, but practically inadvisable: ISPs (especially Yahoo and Hotmail) know about this and they will block deliveries from you (even to addresses that do exist) if you do this a lot. In short, don't do it.

If you're looking to verify an email address the best choice is to send an email and then monitor for any bounces- I myself use AWS SES which gives a response to whether sending was a success. You can find the AWS PHP SDK here.

If you want to use AWS SES, be aware that there is an approval process you need to go through until they'll allow you to send email to anyone.

AStopher
  • 4,207
  • 11
  • 50
  • 75