Reputation: 81721
I want to verify whether an e-mail is real or not. Somebody told me I could do it with DNS check but I don't know how to do this.
Could somebody help me through this problem?
Upvotes: 2
Views: 2437
Reputation: 11
The only reliable way to check if an email address exists is by simulating the process of sending an email, interfacing directly with the mail server for that address. This is exactly what many online email validation services, like e-mail.dev, do.
The process works as follows:
Fetch MX Records: First, a DNS query is made to retrieve the MX records of the email's domain (e.g., gmail.com). These records indicate which mail servers handle emails for that domain.
Connect to the SMTP Server: After obtaining the MX records, you establish a connection with the domain's SMTP server. Simulate Sending an Email: During this connection, you simulate sending an email up to the RCPT TO: command. At this point, the server will respond, indicating whether the email address exists, without actually sending any content.
However, there are some caveats:
Many servers accept all email addresses to prevent "directory harvesting" (the practice of collecting valid email addresses). Some providers use defensive techniques like "catch-all" or other methods to prevent revealing the validity of a specific address. Abusing this technique can get your IP blacklisted by various mail providers.
Upvotes: 1
Reputation: 3732
You can use DNS to determine if a domain is valid/resolving. That wouldn't necessarily mean that a given email address at that domain is valid. The only way to know that is to open an SMTP connection and try to send mail to that user.
Upvotes: 2
Reputation: 16529
DNS check would imply parsing out the domain attached to the email address in question and making sure it resolves/exists.
Be aware that checking that the domain resolves/exists could take time since your application would need to wait for a response from whatever service you use to check if it exists.
Upvotes: 1