ServerObjects Logo


AspMX v1.x

About AspMX

AspMX provides ASP developers with a way to do DNS queries for MX (mailhost) records. By querying the DNS for mail records an Internet developer can determine which servers for a particular domain are designated as incoming SMTP servers. AspMX returns the MX server names in ranked order, the 1st server being the designated domain's primary server and so forth.

AspMX Installation

To use this ASP component move the DLL into a subdirectory (like \winnt\system32 for NT or \windows\system for Win95). Please use the version of regsvr32 that is included with this component or the version that comes with Microsoft ASP (they are the same version).

To register the component on the system change to the directory where you installed the DLL and type:

regsvr32 aspmx.dll

Simple Lookup Example

Using the component is as simple as

  1. Creating the object
  2. Setting a few properties
  3. Calling the DoLookup method

The following code demonstrates how to use AspMX from VBScript. In this example we'll lookup the SMTP servers for microsoft.com.

dim MXRecs, intCount
Set MXRecs = Server.CreateObject ("AspMX.Lookup")
MXRecs.DNS = "255.255.255.0"
MXRecs.Domain = "yahoo.com"
if MXRecs.DoLookup then
  Response.Write "There were " & MXRecs.MXRecords & " mail record(s) found.<br>"
  Response.Write "<table border=1>"
  for intCount = 1 to MXRecs.MXRecords
    Response.Write "<tr><td>" & intCount & "</td><td>" & MXRecs.GetMXRecord(intCount) & "</td></tr>"
  next
  Response.Write "</table>"
else
  Response.Write "An error occurred looking up the domain. The error was: " & MXRecs.Error
end if
Set MXRecs = nothing

By testing the result of the DoLookup method we can determine if the lookup was successful or not.

About purchasing AspMX

  1. Licensing in on a per server CPU basis. Purchasing information is available from http://www.serverobjects.com/products.htm
  2. Evaluation copies will expire. See the Expires property for details on determining when your copy will expire.

About Upgrades

  1. Users can upgrade for free for minor version changes. For example, upgrades from version 1.00 to 1.99 are free. The upgrade from 1.99 to 2.0 may carry an additional license fee.
  2. The latest version of the components are always available at http://www.serverobjects.com/products.htm. If a fee is associated with obtaining the upgrade it will be noted on that page.

Upgrade Instructions

To upgrade the component from a previous version please follow these steps:

  1. Stop all IIS related services such as Gopher, FTP and W3SVC.
  2. Change to the directory where the component is located and type "regsvr32 /u aspmx.dll"
  3. Move the new copy of aspmx.dll to the current directory and type "regsvr32 aspmx.dll"
  4. Restart the necessary services.

Questions about AspMX

How do I determine a cause of lookup failure? Check the Error property to see if the component could determine the cause of failure.
The VerifyAddress method always returns true for xyz.com domain. What's wrong? Services such as AOL accept mail for any username @aol.com. Therefore there is no way to determine what is valid and what is not. The same is true for yahoo.com and hotmail.com. There is no known way to validate addresses for services such as these since their mail servers do not return any errors for invalid usernames.
AspMX does not return MX records with a priority of 0. Why not? Because MX records with priority of 0 are not returned by most, if not all, DNS Servers during a MX request. They are returned only during a general ("ALL") lookup. A value of 0 is as good as "record does not exist", even though the record is technically there. Domains with a 0 value are either not accepting mail or their DNS administrator doesn't know how to properly prioritize their mail server records. Contact the domain, if you can (!!), and inquire as to the status of their mail servers.
"AspMX never works. I get Server object error 'ASP 0177:800401f3'." This error means "Invalid class string" -- in other words the call to CreateObject failed because the name object cannot be found by the OLE sub-system. Causes include:
  1. You really didn't run regsvr32 on the server after all.
  2. You ran regsvr32 but it reported an error.
  3. Someone modified security on part of the registry that's preventing the OLE subsystem from reading all or part of the HKEY_CLASSES_ROOT tree.
  4. The name of the object you are trying to create was mispelled or is incorrect.
  1. Determine if it's a permissions problem

    Add the anonymous user (used by IIS) to the Administrators group. The test page then worked, proving it was a permissions problem. Do not forget to remove the anonymous IIS user from the Admin group!

  2. Determine if it is a file permissions problem:

    After removing the Anonymous user from the Admin group, add failure auditing to the file (aspmx.dll), which will determine if the file was ever accessed (by the lack of the failure event). If it isn't, this makes it clear that the failure is prior to file access but go ahead and check file/directory permissions to make sure the anonymous IIS user can access the file.

  3. Check registry permissions

    Using Regedt32, do find on aspmx.dll. Check the permissions for the key (and sub keys), and make sure that the anonymous user has read rights. Do a find on the class-id, which contains the location value, and version, and check those permissions as well.

"AspMX never works. I get Server object error 80040154." This is the most common error reported. The error means that ASP could not create the object. Causes include:
  1. You never ran regsvr32 on the DLL. See installation section of this document.
  2. You registered the DLL with regsvr32 in one subdirectory and moved it to another.
  3. IIS does not have proper security permissions to access the DLL or the directory you installed it to. See the ASP FAQ (http://www.signmeup.com/faq/) for information on changing security.
  4. Your server may be running low on memory.
  5. Your evaluation copy has expired. If you purchased the product be sure you followed directions to install your product key.

Note: Some users have reported that restarting the server after registering the DLL was required to use the component. This should not be necessary but reportedly works in a few cases

"AspMX works great but sometimes I get 'Server object error 'ASP 0177:80040154'. What's causing this?" If AspMX works fine, then it suddenly stops working and ASP begins to report this error, then you've probably got a memory leak under IIS/ASP. What has happened is that AspMX objects can no longer be created. This could be caused by a) You haven't installed the ASP patches that fix known ASP memory leaks b) You have a filter or extension installed that's leaking memory c) You have another component that's leaking memory.

AspMX 1.x has been run under BoundsChecker to verify that AspMX does not leak memory.

"When running regsvr32 I get an error: 'LoadLibrary ("aspmx.dll") failed. GetLastError returns 0x0000007e."
  1. You are trying to install the AspMX Intel binary on NT for Alpha. Currently there is no Alpha version of AspMX.
  2. The DLL isn't in the same directory you are running regsvr32 from.
  3. The account you are logged in under doesn't have enough security privileges to read the DLL.
  4. The copy you have is corrupt.
How do I upgrade to the latest version? Download the latest "eval" version and follow the upgrade directions provided earlier in this document.
Can I redistribute this component with my products? The license agreement does not permit redistribution of AspMX.
My component is registered. Should the Expires property return a date? No. Registered versions return N/A for an expiration date. The registration process (per the instructions you received) should be run on the server.
What are the minimum security requirements for AspMX and IIS/ASP? Technically, the only requirement AspMail has is that it must have access to the temporary directory as noted in one of the previous troubleshooting tips. But IIS and ASP have certain requirements that must be met to run properly. Thanks to Carl Howell for providing this information.
ASP script directory Creator Owner: Full Control (All)(All)
System: ""
Admin: ""
IUSR: (None)(RX)
\WinNT\ Creator Owner: Full Control (All)(All)
System: ""
Admin: ""
IUSR: (WX)(X)
\WinNT\System32\ System: Full Control (All)(All)
Admin: ""
IUSR: (RX)(RX)
Inetsrv System: Full Control (All)(All)
Admin: ""
Everyone: (RX)(RX)

Technical Support

If you require technical support please see our tech support page at http://www.serverobjects.com/support.htm

AspMX Properties

Property Description
DNS Set the DNS property to the address of your DNS server.

Example:

MXRecs.DNS = "255.255.255.0"

Domain The domain property should be set to the domain that you want to find the MX records for.

Example:

MXRecs.Domain = "microsoft.com"

Error You can test the return value of DoLookup. If a failure occurs the Error property should hold a string value reporting the cause of failure.
Expires If the component is an eval version the expires property will return the date that the component quits functioning.

Example:

Response.Write "Component Expires: " & MXRecs.Expires

MXRecords After performing a DoLookup the MXRecords property holds the number of MX records found for Domain.
RegisteredTo If the component is an eval version the RegisteredTo property will return "Evaluation". Commercial versions return the name of the customer the product is licensed to.

Example:

Response.Write MXRec.RegisteredTo

Timeout Sets the time the component will wait for a response from the DNS server. The default is 20 seconds.

Example:

MXRecs.Timeout = 30

Version Gets the internal component version number.

Example:

Response.Write "Component Version: " & MXRecs.Version

AspMX Component Methods

Method Parameters Return Value Description
DoLookup None True/False based upon success or failure. Does the MX records lookup based on the DNS and Domain properties.

if MXRecords.DoLookup then
  ...
end if

GetMXRecord intWhich

Integer value of the MX record to return. Legal values are <=  MXRecords property after DoLookup.

String Returns the server name of the server for MX record intWhich. Record 1 is the first record, the primary server. If record 2 exists, it is the 2nd designated mail server for the domain and so forth.

Example:

strServer = MXRecords.GetMXRecord(1)

VerifyAddress strFromName, strFromAddress,
strEMailAddress
True/False This function does a mx record lookup for the domain strEmailAddress provided. Then the component attempts to connect to that domain's incoming mail server. The component attempts to verify whether the domain mail server will accept mail for the specified strEMailAddress and returns true or false. If an error occurs you can find what the error was using the Error property. The strFromName, strFromAddress is used to inform the incoming smtp server who is attempting to verify the address. 

See the Questions section of this documentation for notes on AOL, Yahoo and Hotmail addresses.

Sample code for this function is found in AspMX1.asp

 

Copyright © 1998, 1999, 2000 by ServerObjects Inc. All Rights Reserved.