Home Page Customer Care Services Order Now Search Contact Us Privacy Statement ChamberGates
Order Now Web Hosting Dedicated Servers Domain Name Registration Colocation Services Reseller Opportunities Web Design
Page Location
Home Page
Support
atcSmartUpload
aspMX 1.1.8

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).
Function About() As StringAboutProvides some detail on how the component was written.
Property DNSServer As VariantDNSServerRead/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.
Property Domain As VariantDomainRead/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.
Function MX(ByVal Instance As Long) As StringMX(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.
Property MXCount As Long (read only)MXCountRead-only Property that returns the number of MX Records that were detected for a domain.
Function MXPriority(ByVal Instance As Long) As LongMXPriority(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.
Function Resolve() As StringResolve()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.
Property Sender As VariantSenderRead/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.
Property TimeoutValue As IntegerTimeOutValueRead/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.
Function ValidateEMail(ByVal strEMail) As StringValidateEMail(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.
Function Version() As StringVersionThis method returns the current version number of the component.
Function ViewConversation() As StringViewConversation()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)

<%
   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
%>

Copyright (c) 1999-2004 ChamberGates. All Rights Reserved.