FormMail - Using CDONTS on GoDaddy

Form mail provides a way for people to contact you without making your email address visible to spammers. There are several types of server programs Note: In Internet Information Services (IIS), Simple Mail Transfer Protocol (SMTP) service must be enabled and configured in order to use CDONTS.

This page is related to sending form mail using a GoDaddy account, but most of this data can be used at other ISP's.

GoDaddy's example script | CDONTS.NewMail Object
CDONTS_MailForm.asp - objMail.To objMail.From Spam Protection
Sending Attachments | Advantages | IIS 7


GoDaddy's example script

GoDaddy provides the following example CDONTS script - but it does not work. (I wrote this section 02-13-08, it was apparently fixed 05-21-08.) These are the main problems This is a much better example


CDONTS.NewMail Object

CDONTS.NewMail is a Microsoft product, for basic help see - NewMail Object (CDONTS Library)

The properties to, cc, and bcc each allow you to include one or more email addresses - multiple addresses are separated by semicolons.

If the From address is badly formed, then the mail does not go ... and there is no error. Your code MUST validate the address or use a dummy address.


CDONTS_MailForm.asp

This is the file I wrote ... with the to address obscured (to reduce spam) - the from address is just a dummy address that is correctly formatted.


objMail.To

The address the email is sent to should always be read from the server ... never from the html form. In this example, it is hard coded - be sure to change this if you use this code.


objMail.From

CDONTS is very picky, if objMail.From is not a validly formatted email address (the address does not have to actually exist, it just needs a valid format), then CDONTS will not send the email. There are no warnings, no failure codes, there is simply no email.

In addition, the "rules" are not published on the Microsoft web site ... except to say that semicolons are not allowed.

As a result, I decided to simply hardcode a "valid" (but fake) address and to include what the user typed in the body of the message.

The following code reads what the user typed and, if it is not blank, simply adds it to the beginning of the message.


Spam Protection

These lines are used to reduce the probability of getting spam via this script. You should change the field name and the test string.

The following all produce - HTTP 500 - Internal server error

Therefore I decided to use the following which produces - Page Not Found

In addition, you should use a unique filename for this script - perhaps, just add your initials - so that it is harder for spammers to hit lots of accounts.


Sending Attachments

FYI - I have not tried this - How To Send an Attachment in ASP Using CDONTS and the Posting Acceptor


Advantages

There are several reasons that I prefer CDONTS_MailForm.asp over gdform.asp The availability of CDONTS is the first good reason I've seen for picking Windows over Linux for a web server. Unfortunately, Microsoft has announced that future products will NOT support this ... the new version is CDOSYS. The examples above should work if you change to But I have not tested that ... yet.


IIS 7

As of 03-01-12, the GoDaddy CDONTS help page says According to GoDaddy, my site is still using IIS 6.0 .. but CDONTS no longer works. I can't help but wonder. At Using Windows Hosting Form Mailers, the expanded gdform.asp help says


Author: Robert Clemenzi
URL: http:// mc-computing.com / ISPs / FormMail_CDONTS.html