18 November 2011 by Web Bureau
I'm sure you have all came across the problem of automatic spamming of forms using a robot.
One solution to this is to validate the email address on the form by checking that it is a valid domain name and chacking to see if the Mail Server exists.
Dim address As String = "firstname.lastname@example.org"
Dim host As String() = (address.Split("@"c))
Dim hostname As String = host(1)
Dim info As New ProcessStartInfo()
Dim ns As Process
Dim sout As StreamReader
Dim mailserver As String = ""
Dim response As String = ""
info.UseShellExecute = False
info.RedirectStandardInput = True
info.RedirectStandardOutput = True
info.FileName = "nslookup"
info.Arguments = "-type=MX " + sDomain.ToUpper.Trim
ns = Process.Start(info)
sout = ns.StandardOutput
Dim reg As Regex = New Regex("mail exchanger = (?<server>[^\\\s]+)")
Do While (sout.Peek() > -1)
response = sout.ReadLine()
Dim amatch As Match = reg.Match(response)
If (amatch.Success) Then
mailserver = amatch.Groups("server").Value