Note: This is not the complete source code--just the main source file.
You can download the full source (with include files) from our sample code archive by clicking on the diskette icons.
<%@ EnableSessionState=False LANGUAGE="VBSCRIPT" %> <% Option explicit Response.Buffer = false %> <!-- '// ValidateEmail sample script '// '// Demonstrates use of HexValidEmail '// '// Copyright (C) 2000 Hexillion Technologies. All rights reserved. '// --> <!-- #include file="HexGadgets.inc.vbs.asp" --> <!-- #include file="HexValidEmail.inc.vbs.asp" --> <html> <head> <title>Hexillion ValidateEmail sample</title> </head> <body bgcolor="#FFFFFF" text="#000000" vlink="#808080" link="#0000FF"> <% dim oVE dim sAddr, iLevel, lTimeoutDns, lTimeoutSmtp dim bExtraText, bDomainDot, bDomainLiterals, bMx, bVrfy, bCatchAll dim sErr '// Create object set oVE = Server.CreateObject( "HexValidEmail.Connection" ) '// Check for form input, set defaults sAddr = Request( "addr" ) if "" = sAddr then sAddr = "test@hotmail.com" if "" <> request( "level" ) then iLevel = cint( request( "level" ) ) else iLevel = hexVeLevelSmtp end if if "" <> request( "to_dns" ) then lTimeoutDns = clng( request( "to_dns" ) ) else lTimeoutDns = oVE.Timeouts(hexVeTimeoutDnsTotal) end if if "" <> request( "to_smtp" ) then lTimeoutSmtp = clng( request( "to_smtp" ) ) else lTimeoutSmtp = oVE.Timeouts(hexVeTimeoutSmtpTotal) end if bExtraText = ("" <> request( "extra_text" )) bDomainDot = ("" <> request( "domain_dot" )) bDomainLiterals = ("" <> request( "dom_literals" )) bMx = ("" <> request( "mx" )) bVrfy = ("" <> request( "vrfy" )) bCatchAll = ("" <> request( "catchall" )) %> <table cellpadding="5" width="100%"><tr> <td colspan="2" bgcolor="#E1EFFF"><font face="Arial" size="5"><strong>ValidateEmail sample</strong></font> </td></tr> <tr> <td valign="top" bgcolor="#E1EFFF"> <form method="POST" action="<%= request( "SCRIPT_NAME" ) %>"> <table cellpadding="5"> <tr> <td>email address<br> <input type="text" name="addr" size="35" value="<%= server.HTMLEncode( sAddr ) %>"></td> <td>validation level<br> <select name="level"> <% dim i For i = hexVeLevelSyntax To hexVeLevelSmtp Response.Write "<option " if iLevel = i then Response.Write "selected " Response.Write "value=""" & i & """>" & GetVeLevelString( i ) & "</option>" & vbcrlf Next %> </select> </td> <td valign="bottom"><input type="submit" value="Go" name="B1"></td> </tr> <tr> <td>DNS timeout (ms)<br><input type="text" name="to_dns" size="10" value="<%= lTimeoutDns %>"></td> <td colspan="2">SMTP timeout (ms)<br><input type="text" name="to_smtp" size="10" value="<%= lTimeoutSmtp %>"></td> </tr> <tr> <td><input type="checkbox" name="extra_text" value="1" <%= iif( bExtraText, "checked", "" ) %>>allow extra text</td> <td colspan="2"><input type="checkbox" name="domain_dot" value="1" <%= iif( bDomainDot, "checked", "" ) %>>don't require domain dot</td> </tr> <tr> <td><input type="checkbox" name="dom_literals" value="1" <%= iif( bDomainLiterals, "checked", "" ) %>>disallow domain literals</td> <td colspan="2"><input type="checkbox" name="mx" value="1" <%= iif( bMx, "checked", "" ) %>>require MX records</td> </tr> <tr> <td><input type="checkbox" name="vrfy" value="1" <%= iif( bVrfy, "checked", "" ) %>>try VRFY and EXPN</td> <td colspan="2"><input type="checkbox" name="catchall" value="1" <%= iif( bCatchAll, "checked", "" ) %> ID="Checkbox1">test for catch-all</td> </tr> </table> </form> </td> <td valign="top" bgcolor="#E1EFFF"> <table border="0" cellspacing="0" cellpadding="7"> <tr> <td colspan="2">powered by <b><a href="http://www.hexillion.com/software/" target="_top">HexGadgets</a></b> <br><font size="-1"> <a href="http://www.hexillion.com/samples/view_src.asp?name=ValidateEmail.asp" target="_blank">view source</a> | <a href="http://www.hexillion.com/samples/" target="_top">download</a> </font></td> </tr> <% WriteLicenseRow "HexValidEmail", oVE %> </table> </td> </tr></table> <% if "" <> request( "addr" ) then dim iRating '// Identify yourself for SMTP (use your own information here) '// See http://www.hexillion.com/docs/guides/HexValidEmail/concepts/polite_usage.htm oVE.FromDomain = "hexillion.com" '// The domain name of your machine oVE.FromEmail = "HexValidEmail@hexillion.com" '// Email address of technical contact person '// Optional step: set options oVE.Options = oVE.Options or iif( bExtraText, hexVeOptionAllowExtraText, 0 ) _ or iif( bDomainDot, hexVeOptionDontRequireDomainDot, 0 ) _ or iif( bDomainLiterals, hexVeOptionDisallowDomainLiterals, 0 ) _ or iif( bMx, hexVeOptionRequireMx, 0 ) _ or iif( bVrfy, hexVeOptionTryVrfyAndExpn, 0 ) _ or iif( bCatchAll, hexVeOptionTestForCatchAll, 0 ) '// Optional step: set timeouts oVE.Timeouts(hexVeTimeoutDnsTotal).Value = lTimeoutDns oVE.Timeouts(hexVeTimeoutSmtpTotal).Value = lTimeoutSmtp '// Do the validation iRating = oVE.Validate( sAddr, iLevel ) %> <h3><font face="Arial">Results</font></h3> <table border="0" cellspacing="0" cellpadding="5"> <tr> <td align="right" valign="baseline">confidence rating:</td> <td valign="baseline"><tt><b><%= iRating & " - " & GetVeLevelString( iRating ) %></b></tt> <a href="http://www.hexillion.com/docs/guides/HexValidEmail/concepts/interpret.htm" target="_top">what this means</a></td> </tr> <tr> <td align="right" valign="baseline">error:</td> <td valign="baseline"><tt><b><%= GetVeErrorString( oVE.Error ) %></b></tt></td> </tr> </table> <% if len( oVE.LocalPart ) then %> <h3><font face="Arial">Address parts</font></h3> <table border="0" cellspacing="0" cellpadding="5"> <tr> <td align="right" valign="baseline">local part:</td> <td valign="baseline"><tt><b><%= oVE.LocalPart %></b></tt></td> </tr> <tr> <td align="right" valign="baseline">domain:</td> <td valign="baseline"><tt><b><%= oVE.Domain %></b></tt></td> </tr> <tr> <td align="right" valign="baseline">extra text:</td> <td valign="baseline"><tt><b><%= oVE.ExtraText %></b></tt></td> </tr> </table> <% end if if oVE.MxRecs.Count then %> <h3><font face="Arial">MX records</font></h3> <table border="0" cellspacing="0" cellpadding="5"> <tr> <td>preference</td> <td>exchange</td> <td>IP address (if included)</td> </tr> <% dim oMxRec for each oMxRec in oVE.MxRecs WriteLn "<tr>" WriteLn "<td align=""right""><tt><b>" & oMxRec.Preference & "</b></tt></td>" WriteLn "<td><tt><b>" & oMxRec.Exchange & "</b></tt></td>" WriteLn "<td><tt><b>[" & oVE.AddrToString( oMxRec.Addr ) & "]</b></tt></td>" WriteLn "</tr>" next WriteLn "</table>" end if if len( oVE.SmtpSession ) then WriteLn "<h3><font face=""Arial"">SMTP session</font></h3>" WriteLn "<pre>" & server.HTMLEncode( oVE.SmtpSession ) & "</pre>" end if end if set oVE = nothing sub WriteLn( s ) Response.Write s & vbcrlf end sub function iif( b, v1, v2 ) if b then iif = v1 else iif = v2 end if end function %> </body> </html>