74_Email-Security-MX-Records-800x410 #Verify an #Email Address with a #DNS #MX lookup in C# - 74 email security mx records 800x410 - #Verify an #Email Address with a #DNS #MX lookup in C#

Sending an to an invalid has some bad side effects, the most important being, is that your message is not going through to its intended recipient, and on a larger scale, a bad counts towards your bounce ratio with your SMTP provider, which in extreme cases can cause legal issues with EU PECR laws.

You can always, verify the format of an email address using a regex, but this has two issues – one, is that new TLD’s like R;.museum” or R;.家電” might break the regex, and secondly, even if the email is valid. Secondly, some domains are valid, but have no record set up to handle email. like R;” is going to pass any regex, but R;” has no ability to handle email.

So, here’s a bit of code in C# that verifies the domain part of the email;

public static bool VerifyEmailDomain(string domain)
// Install-Package ARSoft.Tools.Net
var resolver = new DnsStubResolver();
var records = resolver.Resolve<MxRecord>(domain, RecordType.Mx);
return records.Any();
catch {
return false;

Now, unfortunately, it’s not possible to check if is valid, even if using this technique, however, if it is really important, then you can check gmail accounts against the API – to verify if the Gmail account has a profile attached.

This technique is the basis behind – a email sending API that bypasses intermediary SMTP servers.


#Verify an #Email Address with a #DNS #MX lookup in C# -  - #Verify an #Email Address with a #DNS #MX lookup in C# #Verify an #Email Address with a #DNS #MX lookup in C# - b - #Verify an #Email Address with a #DNS #MX lookup in C#

Source link


Please enter your comment!
Please enter your name here