VirtualFab Email address checker 1.0


This article was contributed by Fabio Violino

Environment: VB6 SP4, NT4 SP5

OVERVIEW

This VB6 COM component provides realtime Email address checking. This is useful when you want to avoid sending Emails to non-existent accounts. For example, in an ASP page you can check if the user typed his Email address correctly, avoiding storing a wrong information in your users database.



CONTENTS
  1. HOW DOES IT WORK?
  2. COMPONENT FEATURES
  3. INSTALLATION
  4. USAGE
  5. SAMPLE CODE
  6. COMPONENT DOCUMENTATION
  7. CREDITS
  8. DOWNLOADS
  9. HISTORY

HOW DOES IT WORK?

Giving an Email address (e.g. someone@somewhere.com), it executes the following steps:

  1. Separates the Username (someone) from DomainName (somewhere.com);
  2. Queries the configured DNS server if DomainName is valid (exists);
  3. If DNS answers, it tries a SMTP (Simple Mail Transfer Protocol) session with each MX (Mail Exchanger) in that domain, as resulted from DNS query, until a session can be established;
  4. Using SMTP, it verifies that Username exists on that domain, both using the VRFY (verify) command, and a true mail handshake (HELO, MAIL FROM, RCPT TO);
  5. It then returns the result of its search, giving 4 possible results:
Note 1: If the domain exists, but the MX Mail Exchangers aren't in that domain (typical situation with secondary domains handled by ISPs), it's no use to check via SMTP since those machines are instructed to accept all mails for subdomains, and don't check username at all. So we stop and take the partially positive answer.


COMPONENT FEATURES

This component


INSTALLATION


USAGE

To use this component:



SAMPLE CODE (VBScript from an ASP page)

dim oVfab
set oVfab=CreateObject("VFabEmailUtils.EmailCheck")'Create object instance
oVfab.EmailAddr = Request.Form("EMAIL")'Get the address to check from ASP and assign it to object
oVfab.CheckDomain 'Check if domain exists
If oVfab.Result <> 1 Then 'If it exists, then try to check also UserName
  oVfab.SmtpTimeOut = 10 'Give the object 10 seconds to connect to remote SMTP server
  oVfab.CheckUserName 'Tries the SMTP session
End If
Response.Write "<br>" & oVfab.Log (true) 'Displays session log in HTML format
Select Case oVfab.Result
Case 1
  Response.Write "Domain name (<b>" & oVfab.DomainName & "</b>) <b>INVALID</b>"
Case 2
  Response.Write "Domain name: valid - Cannot check account<br>"
Case 3
  Response.Write "Domain name: valid - Username (<b>" & oVfab.UserName & "</b>) <b>INVALID</b>"
Case 4
  If oVfab.RealName <> "???" Then
    Response.Write "Domain Name: valid - Account verified - Real name: " & oVfab.realname & "<br>"
  Else
    Response.Write "Domain Name: valid - Account verified<br>"
  End If
End Select
oVfab.Clear 'Clear connections, logs, and status



COMPONENT DOCUMENTATION

METHODS:
 
Name Description
CheckDomain() Checks the domain part of the Email address to see if it is a valid (existent) domain
CheckUserName() Checks the username via SMTP to see if it is a valid mail account on that domain
Clear() Clear connections, status and log after having completed the task

PROPERTIES:
 
Name Type Read Write Description
EmailAddr String Yes Yes Specify the Email address to check
Result Integer Yes No Get the result of CheckDomain() and/or CheckUserName()
SmtpTimeOut Integer Yes Yes Get/set the timeout in seconds to wait for an SMTP connection
DnsServer String Yes No Set the DNS server IP address to use. Mandatory under Win9x, optional in Windows NT
RealName String Yes No Get the User's Real Name if provided by the SMTP server, after CheckUserName()
DomainName String Yes No Get the domain part of EmailAddr
UserName String Yes No Get the username part of EmailAddr
Log(blnHTML) String Yes No Retrieves the session log, complete with all messages exchanged between the client and the servers. If the optional parameter blnHTML is set to true, it reformat the log with HTML line breaks for an easier reading
SmtpServer String Yes No Get the complete list of MX servers for the domain


CREDITS

This component strongly relies on SimpleDNSResolver by Emmanuel KARTMANN . Please refer to his page for details on the DNS architecture and on his component.


DOWNLOADS
Download source - 23 Kb
Download demo project - 2 Kb


HISTORY

Date Posted: August, 4th 2000