The following vb.net example codes demonstrate how to test email address without specified SMTP server.
Validate Email Address Syntax
Regular expression can be used to validate if an email address is in correct format.
For example: you can use this
pattern to verify if the email address has valid format.
Test Email Address
Even the email address has a valid format, it doesn’t mean the email address is existed in real world. TestRecipients method can be used to test if the email address is valid.
How does it work? Firstly, SmtpClient performs a DNS MX record query. If it retrieves the recipient’s local SMTP server successfully, SmtpClient will try to connect to this server. SmtpClient then performs “RCPT TO” command to test if this SMTP server accepts this email address.
Please always pass null (Nothing in Visual Basic) to SmtpServer paramter except you want to test whether an email address will be accepted by a specified SMTP server.
Before you can use the following codes, please download EASendMail SMTP Component and install it on your machine at first. Full sample proejcts are included in this installer.
Install from NuGet
You can also install the run-time assembly by NuGet. Run the following command in the NuGet Package Manager Console:
If you install it by NuGet, no sample projects are installed, only .NET assembly is installed.
To use EASendMail SMTP Component in your project, the first step is
of EASendMail to your project. Please create or open your project with Visual Studio,
then go to
Add Reference ->
Browse..., and select
Installation Path\Lib\net[version]\EASendMail.dll from your disk, click
OK, the reference of EASendMail
will be added to your project, and you can start to use it to send email
in your project.
Because EASendMail has separate builds for .Net Framework, please refer to the following table and choose the correct dll.
Separate builds of run-time assembly for .NET Framework 1.1, 2.0, 3.5, 4.0, 4.5, 4.6.1, .NET Core 2.1 and .NET Compact Framework 2.0, 3.5.
|File||.NET Framework Version|
Built with .NET Framework 1.1
It requires .NET Framework 1.1, 2.0, 3.5 or later version.
Built with .NET Framework 2.0
It requires .NET Framework 2.0, 3.5 or later version.
Built with .NET Framework 3.5
It requires .NET Framework 3.5 or later version.
Built with .NET Framework 4.0
It requires .NET Framework 4.0 or later version.
Built with .NET Framework 4.5
It requires .NET Framework 4.5 or later version.
Built with .NET Framework 4.6.1
It requires .NET Framework 4.6.1 or later version.
Built with .NET Core 2.1
It requires .NET Core 2.1 or later version.
Built with .NET Compact Framework 2.0
It requires .NET Compact Framework 2.0, 3.5 or later version.
Built with .NET Compact Framework 3.5
It requires .NET Compact Framework 3.5 or later version.
The following example codes demonstrate testing email address using MX DNS lookup.
In order to run it correctly, please change
recipient value to yours.
To get full sample projects, please download and install EASendMail on your machine.
' Add EASendMail namespace Imports EASendMail Module Module1 Sub Main() Try Dim oMail As New SmtpMail("TryIt") ' Set sender email address, please change it to yours oMail.From = "email@example.com" ' Set recipient email address, please change it to yours oMail.To = "firstname.lastname@example.org" ' Do not set SMTP server address Dim oServer As New SmtpServer("") Console.WriteLine("start to test email address ...") Dim oSmtp As New SmtpClient() oSmtp.TestRecipients(oServer, oMail) Console.WriteLine("email address was verified!") Catch ep As Exception Console.WriteLine("failed to test email address with the following error:") Console.WriteLine(ep.Message) End Try End Sub End Module
Firstly, SmtpClient performs a DNS MX record query. If it retrieves the recipient’s local SMTP server successfully, SmtpClient will try to connect to this server. SmtpClient then performs “RCPT TO” command to test if this SMTP server accepts this email address.
Because it totally depends on your networking connection, if your networking connection to the recipient server is bad or your IP address is blocked by the recipient server, test will be failed, but it doesn’t mean this email address is invalid.
Moreover, to prevent email address testing, many email providers accept the recipient address at first no matter if the address is valid or invalid, only after you sent the email data to the server, then the server rejects it if the recipient address is invalid.
Send the email to the recipient without testing. If you don’t get Transport Error and Failure Report in 24 hours, that means the recipient is valid. If you get Failure Report, you should consider to remove this recipient from your mail listing.