Free Support Forum - aspose.com

Showing Email ID as Invalid for internal server domain

Hi,

I have used the “EmailValidator” class to validate the Email ID. While using this class, I found that it is not returning me the correct result.
When i give the Email ID ending with .com or co.in it is showing it as valid but we are having our internal domain for e.g. "abc.local " and email id as “pqr@abc.local” but the class identifying it as “Invalid Email”. When we try to send the email to those address for this domain from Outlook desktop clients, they got send successfully.

I have used the below mentioned code:
e.g
EmailValidator emailValidate = new EmailValidator();
ValidationResult result;

        emailValidate.Validate(emailID,ValidationPolicy.SyntaxAndDomain,out result);

        if(result.ReturnCode == ValidationResponseCode.ValidationSuccess)
            return SuccessPath;
        else
            return FailedPath;

For the above code, it is returning as “Failed Path”.
If in case, I remove the second parameter from Validate method as:
** emailValidate.Validate(emailID,out result);**

Still it showed me the address as “Invalid”.

Now if I change the second parameter of Validate method to check for Syntax only as shown below:
“emailValidate.Validate(emailID,ValidationPolicy.SyntaxOnly ,out result);”

Now for the above code, it is showing the email address ( ‘pqr@abc.local’ ) as Valid but when I tried to pass in-valid address ( ‘pqr@abc_local’), it returned me this as Valid but in actual it is not a valid address.

Kindly suggest me which API should i use for validation of email along with the appropriate parameters?

Thanks.

@priyankabodke,

Thank you for contacting Aspose support team.

Email verification feature works on few set conditions and may not work on all type of customized domains as in your case. The SyntaxOnly flag works such that if there is ‘@’ in between two strings, it may declare it as valid. MailServer option was quite helpful to verify the email addresses by actually connecting to the server, but now-a-days, mostly servers have restricted such validation and thus it is declared as “deprecated” by Aspose.Email as well.

Regarding the third option, SyntaxAndDomain, it first verifies the syntax and then domain of the email addresses.

It seems that you may use this validation feature for standard email addresses, and for local mail server you may implement your own logic along with this validation wherever required.