How to check if an email address exists without sending an email?

前端 未结 14 1746
半阙折子戏
半阙折子戏 2020-11-22 00:28

I have come across this PHP code to check email address using SMTP without sending an email.

Has anyone tried anything similar or does it work for you? Can you tell

14条回答
  •  鱼传尺愫
    2020-11-22 01:05

    I can confirm Joseph's and Drew's answers to use RCTP TO: . I would like to add some little addenda on top of those answers.

    Catch-all providers

    Some mail providers implement a catch-all policy, meaning that *@mydomain.com will return positive to the RCTP TO: command. But this doesn't necessarily mean that the mailbox "exists", as in "belongs to a human". Nothing much can be done here, just be aware.

    IP Greylisting/Blacklisting

    Greylisting: 1st connection from unknown IP is blocked. Solution: retry at least 2 times.

    Blacklisting: if you send too many requests from the same IP, this IP is blocked. Solution: use IP rotation; Reacher uses Tor.

    HTTP requests on sign-up forms

    This is very provider-specific, but you sometimes can use well-crafted HTTP requests, and parse the responses of these requests to see if a username already signed up or not with this provider.

    Here is the relevant function from an open-source library I wrote to check *@yahoo.com addresses using HTTP requests: check-if-email-exists. I know my code is Rust and this thread is tagged PHP, but the same ideas apply.

    Full Inbox

    This might be an edge case, but when the user has a full inbox, RCTP TO: will return a 5.1.1 DSN error message saying it's full. This means that the account actually exists!

    Disclosure

    I run Reacher, a real-time email verification API. My code is written in Rust, and is 100% open-source. Check it out if you want a more robust solution:

    Github: https://github.com/amaurymartiny/check-if-email-exists

    With a combination of various techniques to jump through hoops, I manage to verify around 80% of the emails my customers check.

提交回复
热议问题