Virtual Fab Email address Checker 1.0
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
- HOW DOES IT WORK?
- COMPONENT FEATURES
- INSTALLATION
- USAGE
- SAMPLE CODE
- COMPONENT DOCUMENTATION
- CREDITS
- DOWNLOADS
- HISTORY
HOW DOES IT WORK?
Giving an Email address (e.g. someone@somewhere.com), it executes the following steps:
- Separates the Username (someone) from DomainName (somewhere.com);
- Queries the configured DNS server if DomainName is valid (exists);
- 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;
- 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);
- It then returns the result of its search, giving 4 possible results:
- The domain doesn't exist. Negative answer
- The domain exists, but it isn't possible to check username (see note 1). Partially positive answer.
- The domain exists, but the username doesn't exist. Negative answer
- Both the domain and the user exist, fully positive answer
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
- Finds DNS server as configured on the local machine. You must have an active connection to the internet for this component to work properly
- Sends DNS requests using the SimpleDNSResolver component (see credits below)
- Receives DNS answers via UDP
- Establishes an SMTP session, via a standard Winsock.ocx TCP connection
- Talks with remote mail server to find out information on user
- Provides complete session log (DNS and SMTP) for debugging
- Provides very small executable (it is an ActiveX DLL less than 50K in size)
- It hasn't an user interface and must be used by any language that supports ActiveX components (e.g. VBScript, ASP, VB, VC++, etc...)
- Runs on Windows NT 4.0 SP5, Windows 2000 (not tested), Windows 95 (not tested) and Windows 98 (not tested)
- Compiles with VB 6.0 Service Pack 4 (tested), but it can be compiled also in previous VB versions (such as 5) that support Winsock.ocx
INSTALLATION
- Download the package, unzip it into your preferred directory;
- Copy the VfabEmailUtils.DLL into your SYSTEM directory (C:\WINNT\SYSTEM32 for Windows NT, or C:\WINDOWS\SYSTEM for Win9x)
- Register the component into the registry:
- REGSVR32 C:\WINNT\SYSTEM32\VfabEmailUtils.dll
- IMPORTANT: to have this component working properly, you MUST install Emmanuel KARTMANN's Simple DNS Resolver v1.0. Please click here to read about how to install his package. See credits below.
USAGE
To use this component:
- Create an instance of the component;
- Put properties:
- EmailAddr
- SmtpTimeOut
- DNS server address (only under Win9x)
- Call the CheckDomain method
- Test the Result property: if it is not equal to vfabInvalidDomain (1) then you can
- Call the CheckUserName method;
- Then test the Result property to get the final result:
- vfabNotVerified = 0
- vfabInvalidDomain = 1
- vfabValidDomain = 2
- vfabValidDomainInvalidAccount = 3
- vfabValidDomainValidAccount = 4
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.

Comments
Some Considerations
Posted by Legacy on 11/24/2002 12:00amOriginally posted by: Dario
Hi,
thank's to Fabio's code we have a nice starting point for a really fail-proof e-mail checker. I think he coded this for his situation and didn't intend to use it for cehcking mailboxes that were outside his domain. Actually the CheckDomain function will not do anything if the mailbox is not in your domain. Furthermore the SMTP connection made is not RFC-821 compilant, you need to specify the MAIL FROM and RCPT TO address in this form: RCPT TO:<someone@somewhere.tld> , otherwise the mail server will refuse it. Another error I've noticed is that the function will not check the next SMTP server if the first one is not responding.
We should also make a spelling check (invalid characters etc.) of the email address before calling CheckDomain.
We don't need the Simple DNS Resolver if we are on a windows NT matchine with WSH 2.0 installed. We can simply execute "nslookup -querytype=mx domain.tld dnsServer" from the WScript.Shell and get the mail exchangers from there.
One last point I have to underline is that the only way to check if the mailbox is 100% valid and ready to recive is to realy send a message to it. The reason is that some mail servers (ex. yahoo) will reply to "RCPT TO:<someone@somewhere.tld>" with "250 OK" even if the mailbox is not valid. In this case the only thing you can do is go ahead and send some "DATA" and finish the message with a "." , after this the server will reply with "250" and you are 100% shure the mailbox is valid.
That's all, if you have any questions or more ideas feel free to contact me.
Ciao
ReplyDario
Re: CSimpleDNSClient
Posted by Legacy on 08/19/2002 12:00amOriginally posted by: sachin
ReplyCSimpleDNSClient.dll
Posted by Legacy on 07/26/2002 12:00amOriginally posted by: PreetiRathore
Hello
Can I create CSimpleDNSClient.dll in Visual Basic 6.0. Emmamunel's code is in C++. Please help me to incorporate this code in vb
Please help
Replypreeti