In building forms, newsletters, etc it is very common to verify that an email that was entered by user is formatted properly. There are many ways to do this. You can use javascript, jquery, server side, etc.. You can use regex or some other tool but in the end someone could enter something like 12345@IAmAHack.com and it will validate every time. What if there was a way for you to take it one step further and actually verify the email is a valid email and not just a valid “formatted” email.
I came across one such api on mashape.com. This site is dedicated to providing a way to consume API’s. If you have never tried it, I would encourage you to go over there and check this one out. There are really no limitations and it is another way to actually verify that an email address is valid.
You have to Get an API Key (really not painful at all) and add this to your code. Here is a sample of code in vb.net that will actually return a real result. (True the email is valid, False if it is not)
You can see that I am returning the result into an object.
If you don’t know what unirest_net.dll is or you want to set up a blank project use mashape API then check out my last article.
Note: Take notice of where to enter your APIKey
[code language=”vb”]
Imports unirest_net.http
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
‘https://www.mashape.com/pozzad/email-validator-1#!documentation
Dim jsonresponse As HttpResponse(Of myEmailtest) = Unirest.[get]("https://pozzad-email-validator.p.mashape.com/emailvalidator/validateEmail/david@arvixe.com") _
.header("X-Mashape-Authorization", "EnterYourAPIKeyHere") _
.asJson(Of myEmailtest)()
Response.Write(jsonresponse.Body.isValid)
End Sub
End Class
Public Class myEmailtest
Public Property isValid As String
End Class
[/code]
Looking for quality web hosting? Look no further than Arvixe Web Hosting!