Menu

Want to work with us? We're on the lookout for a UX/UI Designer and Digital Project Manager.

We're hiring

Validate Email Host

Web Bureau


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

Grow your businessStart a project with us today.