ASP MX Component
ASPMX is an ASP component that provides simple DNS lookup of mail exchanger MX records. This is useful in applications where you need to know the hostname of the mail exchanger(s) for a given domain. For example, if someone provides you with an email address like joebloggs@microsoft.com, ASPMX will lookup the names and priorities of the mail servers that are registered as mail exchangers for microsoft.com. The Component can also be used to validate an email address. It does this by attempting to connect to the lowest cost mail exchanger and simulating an SMTP transmission for the email address passed. In general, this can be used to determine whether the email address joebloggs@microsoft.com really exists (or at least whether mail will be accepted for the user). The component is a form of freeware that I call donationware. It can be downloaded from here (1,494,332 bytes). If you have Visual Basic V6.0 SP5 runtimes and the Microsoft Winsock Control V6.0 SP5 already loaded on your system, you can download the bare DLL (106,496 bytes) by clicking here. You can then register it yourself using regsvr32.exe. If you are not fully conversant with component registration or are not sure if you have the required runtimes, rather download the full installation.
ASP MX Component Properties & Methods
| About |  | Provides some detail on how the component was written.
| DNSServer |  | Read/Write Property that allows you set the DNS Server to use. Can be either a hostname such as NS.ERS.IBM.COM or an IP address such as 204.146.173.35.
| Domain |  | Read/Write Property that allows you specify which domain you want to look the MX record up for. This has to be a fully qualified domain name, such as internext.co.za.
| MX(i) |  | This is a method that provides you with the hostname(s) of a domain's MX record(s). It takes a long parameter that represents the ith MX record. The parameter i is in the range of 1 to MXCount.
| MXCount |  | Read-only Property that returns the number of MX Records that were detected for a domain.
| MXPriority(i) |  | This is a method that provides you with the priorities of a domain's MX records. It takes a long parameter that represents the ith MX priority record. The parameter i is in the range of 1 to MXCount. No assumptions should be made about the sort order of the Priority List.
| Resolve() |  | The method that performs the actual lookup. Returns a string parameter that is an empty string if the lookup was successful and an error message if it wasn't.
| Sender |  | Read/Write Property that can be used to set the sender email address that is used during the execution of the ValidateEMail method. If not specified, the email address being validated will be used during the SMTP mail from phase. This should be an email address like joe@microsoft.com.
| TimeOutValue |  | Read/Write Property that can be used to set the timeout value. This is the maximum time (in seconds) that the component will wait for the DNSServer to resolve the MX details when executing the Resolve method. The acceptable range is 1 to 300.
| ValidateEMail(strEMail) |  | This method checks whether the email passed as parameter strEMail is valid. If it is valid, an empty string is returned. If not (or an error occurred), an appropriate message is returned. Note that the property TimeOutValue will be used in all communications with the nominated remote SMTP Server, so it is a good idea to increase this accordingly as shown in the example below.
| Version |  | This method returns the current version number of the component.
| ViewConversation() |  | This method returns details on the SMTP conversation conducted during the last call to ValidateEMail. It is there purely for debugging purposes to see why a specific call to ValidateEMail may have failed (Most reasons for ValidateEMail failing can be deduced from this)
Sample ASP Code for using the component
    <%
       Dim DNSMX                                          ' Instance of the component
       Dim A                                              ' A temporary String

       Set DNSMX = Server.CreateObject("ASPMX.Resolver")  ' Create the Component
       DNSMX.DNSServer = "196.25.1.1"                     ' Set the DNS Server to user
       DNSMX.Domain = "microsoft.com"                     ' Set the domain to lookup
       DNSMX.TimeOutValue = 10                            ' Set the Timeout value to 10 seconds
       A = DNSMX.Resolve()                                ' Attempt resolving the MX record(s)
       If Len(A) > 0 Then
         Response.Write "Error : " & A
       Else
         Response.Write "There are " & DNSMX.MXCount & " records :"
         For X = 1 To DNSMX.MXCount
           Response.Write "<BR>" & DNSMX.MX(X) & " (" & DNSMX.MXPriority(X) & ")"
         Next
       End If

       DNSMX.TimeOutValue = 30                            ' Change Timeout value to 30 seconds
       DNSMX.Sender = "tester@microsoft.com"              ' Set the sender email address to use
       A = DNSMX.ValidateEMail("bill@microsoft.com")      ' See if bill@microsoft.com is valid
       If Len(A) = 0 Then                                 ' If the response is of zero length, it is valid
         Response.Write "bill@microsoft.com exists"
       Else                                               ' If not, an error occurred or there is
         Response.Write A & "<BR>"                        ' no such user. Write the error.
         A = DNSMX.ViewConversation()                     ' Also write details of the last
         A = Replace(A,vbcrlf,"<BR>")                     ' SMTP conversation for debugging
         Response.Write "The error might be due to an "   ' purposes.
         Response.Write "SMTP error. The last "
         Response.Write "conversation went as follows:"
         Response.Write "<BR>" & A
       End If
       Set DNSMX = Nothing
    %>
Downloads
| Full Installation (Component + Runtimes) | 1,494,332 bytes
| Dynamic Link Library only | 106,496 bytes
Revision History
| April 10, 2002 | Updated Release V1.1.8. Reduces the CPU utilization during method calls by putting the thread to sleep for 100ms. Thanks to Tommie Goldhammer for suggesting this. The release also provides the ViewConversation() method to trace any problems with SMTP connections during ValidateEMail().
| Nov 19, 2001 | Updated Release V1.1.6. To accommodate communications with overworked mailservers during ValidateEMail(), ASPMX will now wait for full response lines from the SMTP Server between steps. Thanks to tima@tima.uk.com for reporting this.
| Sep 24, 2001 | Updated Release V1.1.5. To assist with the Validate() issues of 17 July 2001, ASPMX will now allow you to explicitly set the Sender Property to a zero length string (""). This will cause ASPMX to specify mailfrom: <> during the SMTP conversation. Thanks to Tom Klarner for reporting this.
| Sep 24, 2001 | Included in Release V1.1.5. Fixed integer overrun on using the TimeoutValue property while executing ValidateEMail(). This bug limited the timeout value to 32 seconds. The valid range for TimeOutValue has also been updated to accept values between 1 and 300 seconds.
| Sep 24, 2001 | Included in Release V1.1.5. On Object creation, ASPMX will now attempt to determine the DNS Server to use by selecting the first DNS Server in the Windows TCP/IP settings. If no DNS Servers are found, ASPMX will default to 196.25.1.1 (a large South African DNS Server). The actual DNS Server to use can still be overridden with the DNSServer property.
| July 17, 2001 | Updated Release V1.1.4. Adds the Sender property to assist with mail servers that have problems during the mail from: phase.
| June 27, 2001 | Updated Release V1.1.3. Alters the ValidateEMail method to also check for e-mail addresses at a specific host and not just at the mail exchanger for a domain.
| June 3, 2001 | Updated Release V1.1.0 to add ValidateEMail method
| April 1, 2001 | Updated Release V1.0.1 using Visual Studio 6 SP5
| March 11, 2001 | Initial Release V1.0.0 using Visual Studio 6 SP4
Donationware
As every programmer knows, a fair amount of time goes into developing a product. Programmers are normally nice guys but are not the sharpest business people. As a result, we tend to give away things for free. DONATIONWARE is my idea of letting you make a contribution if you feel that you would like to. So, if you like the software and feel that it saved you time, you can make a US$10 contribution. Or you can just use it for free and feel bad about it ;). Either way, the software is the same. It still works and it is not crippled. You will not receive a new super version of the component when you register. The free and the registered versions are the same. You do not HAVE to buy it, but if you want make a contribution, feel free to do so by clicking here or by clicking on the button below. Thanks ;)
Disclaimer
This component is provided as is and without any guarantees or promises. You use it entirely at your own risk. It was written with care but cannot be certified to contain no bugs or errors. You also cannot hold me responsible if it crashes your server or starts World War III. Since it's free, I do not guarantee performance, support or error-free operation.
Contact Information
This Webpage was written in a great hurry, so please don't judge the component on the appearance of this page. One day when I grow up, I'll make a decent page. If you wish to mail me any comments, feel free to do so at stefan@internext.co.za
| accesses since 11 March 2001