Close
Menu
Want to work with us? We're on the lookout for digital experts.
We're hiring
04 June 2011
by Web Bureau
It is quite easy to by-pass standard email validation something as simple as me@me.com is a valid email address. To add some extra validation we can use sockets to validate the email address host. The following function will take validate the email address hostname.
Public Shared Function fun_ValidateEmailHost(ByVal Email As String) As Boolean
Try
Dim host As String() = Email.Split("@")
Dim hostname As String = host(1)
Dim soc As Socket
Dim entry As IPHostEntry = Dns.GetHostEntry(hostname)
Dim EndPoint As IPEndPoint = New IPEndPoint(entry.AddressList(0), 25)
soc = New Socket(EndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
soc.Connect(EndPoint)
Return True
Catch ex As Exception
Return False
End Try
End Function
This site uses essential cookies for parts of the site to operate and have already been set. Find out more about how we use cookies and how you may delete them. You may delete cookies, but parts of the site will not work.