We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Email address verification


Is there any method to verify an email address for validity using this API?

Hi Acton,

Aspose.Email provides EmailValidator class which can be used to verify the mail server, syntax and domain. You may please give a try to the following sample code and let us know the feedback.

string emailToTest = "validuser@gmail.com";<o:p></o:p>

EmailValidator ev = new EmailValidator();

ValidationResult result = new ValidationResult();

ev.Validate(emailToTest, ValidationPolicy.MailServer, out result);

if (result.ReturnCode == ValidationResponseCode.ValidationSuccess)

Console.WriteLine("MailServer passed");


Console.WriteLine("MailServer failed");

ev.Validate(emailToTest, ValidationPolicy.SyntaxAndDomain, out result);

if (result.ReturnCode == ValidationResponseCode.ValidationSuccess)

Console.WriteLine("SyntaxAndDomain passed");


Console.WriteLine("SyntaxAndDomain failed");

ev.Validate(emailToTest, ValidationPolicy.SyntaxOnly, out result);

if (result.ReturnCode == ValidationResponseCode.ValidationSuccess)

Console.WriteLine("SyntaxOnly passed");


Console.WriteLine("SyntaxOnly failed");

We bought aspose.email for the project I am working on and in trying your code but I got the following error when verifying a valid email address of a customer… any ideas?

result.Message =
"Mail server error found in the mail validation Last Exception: An attempt was made to access a socket in a way forbidden by its access permissions xxx.xxx.xxx.xxx:25"

Thank you

Hi Luis,

Can you please share the email address that you are testing at your end? We’ll have to test that at our end for assisting you further.


I am testing from a computer at work which is a corporation with a large IT group. The only emails that pass the test are the ones that exist in the exchange server, any other email like any gmail or Hotmail accounts fails with the same message

Hi Luis,

We have analysed your shared information and have come to know that this is actually not a bug of Aspose.Email component rather a mail server policy. Please note that some mail servers (like Gmail and Hotmail) have switched off the address checking feature to protect the mail accounts from spammers. Therefore, you may not be able to use Verify Email feature with such mail servers.

Hello Muhammad,

Thank you for your reply

There is a little misunderstanding here, just to clarify things: The code I provided checking against Gmail and Hotmail accounts works fine when run at home. It does not work only when it is run at work. Maybe the network at work does not allow your validation functionality to work for some reason (some sort of permission).

Note that the debug screen-shot I posted is the one I took at work not at home (again at home it works fine) Any ideas? What does that permissions error message means exactly? where does that IP address with port 25 come from? This are the kind of questions that I am having.

Could yo share some code or pseudo-code showing how your validation is been implemented? I believe it does not utilizes exchange for anything since no aspose …Client class is involved correct?

Also of the three checks which ones (besides syntax checking) works against all servers? Note that we will have separate functionality looking into the bounced emails

Thank you in advance


Hi Luis,

Thank you for sharing the additional information.

We don’t have access to the implementation details of this feature. Could you share with us if your workplace has some firewall installed or not? In both the scenarios at your end, we need the information of difference between these two setups. Please share the .NET framework information as well with us that you are targeting your application.

Hello Muhammad

Thank you for staying on top of these questions. Here is what I know so far

1. At work (where your validation fails): These are the County government facilities where I work. They have both Exchange server 2010 and 2013. More than a thousand employees work here so I will have to ask the IT group any specific question you may have regarding firewall, but I am positive there is a firewall. How does your validation functionalist works behind the firewall or what to do to make it work?
Again at work the only email addresses that succeed are the County email addresses the ones created internally with the County exchange servers. Any other gmail, hotmail, or any customer email address we’ve tested has failed to validate properly your Aspose email validation functionality.

The .net framework we are targeting is .net 4.0 (my work machine running with Windows 7 and with Visual Studio 2012) due to some legacy applications’ requirements.

2. At home (where your validation functionality succeeds): It is a simple Cox cable connection (cox is the local cable provider). I do have a static IP address at home. The target framework is .net 4.0 as well, and your validation functionality properly validates all email addresses we have tested including County email accounts as well as google, yahoo, Hotmail, etc.

Any Ideas what do we need to do to make it function properly (your email validation functionality that is) in particular if it needs to be behind the fire wall at work (County government facilities)?

Thanks in advance

Hi Luis,

Thank you for sharing additional information.

This seems to be some issue posed by the network policies at your end related to DNS settings at your work place. Please share your sample code that you are using at your home and workplace. We assume that it is the same code that you are using at both the places. Also, please provide some test Gmail address that you are able to validate at your work place. We shall look into it further and investigate the issue at our end.