Free Support Forum - aspose.com

EmailValidator problem validating

Using Aspose.Network.Verify.EmailValidator

Running the code at the bottom of this post produces a result of -2, DomainValidationFailed for a working email address. I've run it both with and without the DnsServer set. I can't find much documentation, examples, or forum posts on this other than forum posts that went unanswered.

Please advise how to get email validation working.

Thanks,

James Vitale

Dim ev As New Aspose.Network.Verify.EmailValidator

Dim result As Aspose.Network.Verify.ValidationResult

ev.DnsServers = New String() {"68.87.74.162", "68.87.68.162"}

ev.Validate("jvitale@buildercms.com", result)

If (result.ReturnCode = Aspose.Network.Verify.ValidationResponseCode.ValidationSuccess) Then

Else

End If

Hello,

I think it is caused by you cannot get the MX record in your computer for some network settings.

The Domain validation is trying to look up the MX record by using DNS protocol. If it cannot get valid records, the validation will fail.

In our test environment, we can get the mx records properly from the dns resolving. For your cases, if you provide the MX record to that domain, you can continue to do the mail server check. Please check the attached code.

void DomainValidatingEventHandler(object sender, DomainValidatingEventArgs e)
{
if (e.Domain == "buildercms.com")
{
e.MailExchangeServers = new string[] {
"MX00.1AND1.com","MX01.1AND1.com"
};
e.Result = new ValidationResult(ValidationResponseCode.ValidationSuccess);
e.Skip = true;
}
}


public void Test_Email_Address_buildercms()
{
string[] emails = new string[] {
"jvitale@buildercms.com"
};
foreach (string email in emails)
{
if (string.IsNullOrEmpty(email))
break;
EmailValidator ev = new EmailValidator();
ev.DomainValidating += DomainValidatingEventHandler;

ValidationResult result;
ev.Validate(email, out result);
if (result.ReturnCode == ValidationResponseCode.ValidationSuccess)
{
System.Diagnostics.Debug.WriteLine("Pass:" + email);
}
else
{
System.Diagnostics.Debug.WriteLine("Fail:" + email);
}
}
}

How can it be a failure of my computer to look up the MX records? My computer has full internet access. Isn't it your component that goes out and gets the MX records and does the DNS lookup?

According to your code example, I can only validate domains when I know the mail servers in advance. This makes this functionality useless to me. Please tell me how I can use this component to validate emails that users enter on my webpage.

Thanks,

James

Hello, James,

Yes, Aspose.Network will try to do MX record lookup itself. But we don't have idea why the mx record lookup fails on your environment. Could you pop up this issue to your network administrators? Maybe they have the answers. Anyway, we will continue to investigate about this issue. I will get back to you shortly.

The sample code I posted before is given the mx record lookup result to the mail validator, then it can do the mail server validation. We are trying to add more support for it -- for example provide some way to cache these mx recods to disk and then load it up when validating.

How's your product scenario? The email addresses that you need to validate are from different domain? How many domain of them? Could you please give me more details. Then we can work out some solutions.

Best regards.