Nicole Rutter's Blog
Posted At : February 1, 2008 12:10 PM | Posted By : Nicole Rutter

Go Daddy ASP CDONTs form mail issue CONTINUED

I have received a lot of emails on the go daddy form mail issue. I have written an example to post for everyone that should help you out in a little more detail. This is a very raw form but it has been tested and it does work.

Below you will find an example of a very basic form for an estimate. This form will collect the data and post to a page called start_thanksN.asp. So you will need to start out by creating a blank HTML page (or whatever language you decide to use). You will enter your form data and post the data to your processing page. For this example I am posting mine to start_thanksN.asp.

<html>
<head>
<title>Example for submit using ASP and Cdont</title>
</head>

<body>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
   <tr>
   <td width="94%" valign="top">
       <form name="form1" method="post" action="start_thanksN.asp" onSubmit="return checkForm()">
    <input type="hidden" name="recipients" value="YOUR EMAIL ADDRESS">
<input type="hidden" name="subject" value="Form Submission">
<input type="hidden" name="redirect" value="thankyou.html">
<table width="60%" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr valign="top">
    <td width="27%" nowrap><div align="right"><font size="2">Name:</font></div></td>
<td width="73%"><div align="left"><input name="txtName" type="text" id="txtName12" size="30"></div></td>
</tr>
<tr valign="top">
   <td nowrap><div align="right"><font size="2">Address:</font></div></td>
<td><div align="left"> <input name="txtAddress" type="text" id="txtAddress2" size="30"></div></td>
</tr>
<tr valign="top">
<td nowrap><div align="right"><font size="2">City:</font></div></td>
<td><div align="left"><input name="txtCity" type="text" id="txtCity2" size="30"></div></td>
</tr>
<tr valign="top">
<td nowrap><div align="right"><font size="2">State:</font></div></td>
<td><div align="left"><input name="txtState" type="text" id="txtState2" size="30"></div></td>
</tr>
<tr valign="top">
<td nowrap><div align="right"><font size="2">Zip:</font></div></td>
<td><div align="left"><input name="txtZip" type="text" id="txtZip2" size="15"></div></td>
</tr>
<tr valign="top">
<td nowrap><div align="right"><font size="2">Phone:</font></div></td>
<td><div align="left"><input name="txtPhone1" type="text" id="txtPhone12" size="30"></div></td>
</tr>
<tr valign="top">
<td nowrap><div align="right"><font size="2">Alternate Phone:</font></div></td>
<td><div align="left"><input name="txtPhone2" type="text" id="txtPhone22" size="30"></div></td>
</tr>
<tr valign="top">
   <td nowrap><div align="right"><font size="2">Best Time to Call:</font></div></td>
<td><div align="left"><font size="2"><input name="chkMorning" type="checkbox" id="chkMorning" value="Morning">Morning
<input name="chkAfternoon" type="checkbox" id="chkAfternoon" value="Afternoon">Afternoon <br>
<input name="chkEvening" type="checkbox" id="chkEvening" value="Evening">Evening
<input name="chkAny" type="checkbox" id="chkAny" value="Any Time">Any Time </font></div></td>
</tr>
<tr valign="top">
   <td nowrap><div align="right"><font size="2">Email Address:</font></div></td>
<td> <div align="left"><input name="txtEmail" type="text" id="txtEmail" size="30"></div></td>
</tr>
<tr valign="top">
   <td nowrap><div align="right"><font size="2">Service Type:</font></div></td>
<td nowrap><div align="left"><input name="chkDesign" type="checkbox" id="chkDesign" value="Design">
<font size="2">Design</font><font size="2">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="chkNet" type="checkbox" id="chkNet" value="Net">
. Net<br>
<input name="chkColdFusion" type="checkbox" id="chkColdFusion" value="ColdFusion">
ColdFusion
<input name="chkPHP" type="checkbox" id="chkPHP" value="PHP">
PHP <br>
<input name="chkFlex" type="checkbox" id="chkFlex" value="Flex">
Flex<br>
<input name="chkASP" type="checkbox" id="chkASP" value="ASP">
ASP
<br>
                              <input name="chkDev" type="checkbox" id="chkDev" value="Development">
                              Development<br>
</font></div></td>
</tr>
<tr valign="top">
<td nowrap><div align="right"><font size="2">Current Site URL:</font></div></td>
<td><div align="left"><input name="txtURL" type="text" id="txtURL" size="45">
</div></td>
</tr>
<tr valign="top">
<td nowrap><div align="right"><font size="2">Message:</font></div></td>
<td><div align="left"><textarea name="txtMessage" cols="30" rows="4" id="txtMessage"></textarea></div></td>
</tr>
</table>
<div align="center"><br><input type="submit" name="Submit" value="Submit"><br></div>
         </form>
    </td>
    </tr>
</table>
</body>
</html>
Now that we have our form created we need to post our form to our processing page. You will need to create a blank .ASP page. The page should be the same name as your post in your form tag in your html page. This is where we will place all of our CDONTs code and post a confirmation that the email was sent.

<%@ LANGUAGE = VBScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Thank you</title>

<%
Dim theName
theName = request("txtName")
Dim theAddress
theAddress = request("txtAddress")
Dim theCity
theCity = request("txtCity")
Dim theState
theState = request("txtState")
Dim theZip
theZip = request("txtZip")
Dim thePhoneNum
thePhoneNum = request("txtPhone1")
Dim thePhoneNum2
thePhoneNum2 = request("txtPhone2")
Dim callTimeMorning
callTimeMorning = request("chkMorning")
Dim callTimeAfternoon
callTimeAfternoon = request("chkAfternoon")
Dim callTimeEvening
callTimeEvening = request("chkEvening")
Dim callTimeAny
callTimeAny = request("chkAny")
Dim theEmail
theEmail = request("txtEmail")
Dim serviceDesign
serviceDesign = request("chkDesign")
Dim serviceNet
serviceNet = request("chkNet")
Dim serviceColdFusion
serviceColdFusion = request("chkColdFusion")
Dim serviceFlex
serviceFlex = request("chkFlex")
Dim serviceRaking
serviceRaking = request("chkRaking")
Dim serviceASP
serviceASP = request("chkASP")
Dim servicePHP
servicePHP = request("chkPHP")
Dim serviceDev
serviceDev = request("chkDev")
Dim siteURL
siteURL = request("txtURL")
Dim theMessage
theMessage = request("txtMessage")

if not theName = "" then
'sends email to myself

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Testing CDO form mail by Nicole Rutter"
myMail.From=theEmail
myMail.To="nicole@cfwebtools.com"
BodyText = "*********** Request For Estimate ***************" &chr(13) &chr(10)

BodyText = BodyText & "Name: " & theName &chr(13) &chr(10) & "Address: " & theAddress &chr(13) &chr(10) & "City: " & theCity &chr(13) &chr(10) & "State: " & theState &chr(13) &chr(10) + "Zip Code: " & theZip &chr(13) &chr(10)

BodyText = BodyText & "Phone Number: " & thePhoneNum &chr(13) &chr(10) & "Alternate Phone Number: " & thePhoneNum2 &chr(13) &chr(10) & "Best Time to Call: " & callTimeMorning & " " & callTimeAfternoon & " " & callTimeEvening & " " & callTimeAny &chr(13) &chr(10)& "Email Address: " & theEmail &chr(13) &chr(10) &chr(13) &chr(10) & "Services Requested: " &chr(13) &chr(10)
Dim ServiceRequest
if not serviceDesign = "" then
ServiceRequest = serviceDesign &chr(13) &chr(10)
end if
if not serviceNet = "" then
ServiceRequest = ServiceRequest + serviceNet &chr(13) &chr(10)
end if
if not serviceColdFusion = "" then
ServiceRequest = ServiceRequest + serviceColdFusion &chr(13) &chr(10)
end if
if not serviceFlex = "" then
ServiceRequest = ServiceRequest + serviceFlex &chr(13) &chr(10)
end if
if not serviceRaking = "" then
ServiceRequest = ServiceRequest + serviceRaking &chr(13) &chr(10)
end if
if not serviceASP = "" then
ServiceRequest = ServiceRequest + serviceASP &chr(13) &chr(10)
end if
if not servicePHP = "" then
ServiceRequest = ServiceRequest + servicePHP &chr(13) &chr(10)
end if
if not serviceDev = "" then
ServiceRequest = ServiceRequest + serviceDev &chr(13) &chr(10)
end if

BodyText = BodyText & ServiceRequest &chr(13) &chr(10) & URL: " & siteURL & " URL" &chr(13) &chr(10) &chr(13) &chr(10)
BodyText = BodyText & "
Message: " & theMessage &chr(13) &chr(10)

myMail.TextBody=BodyText
myMail.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="
relay-hosting.secureserver.net"
'Server port
myMail.Configuration.Fields.Item _
("
http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=25
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing


end if
%>
</head>
<body>
<table width="807" border="0" align="center" cellpadding="p" cellspacing="0">
<tr>
<td width="622" valign="top" bgcolor="#FFFFFF">
The form has been sent thank you. <br> <br></td>
</tr>
</table>

I hope this will give everyone a little better understanding of how to get your form mail working on go daddy. If your wondering how the email will look to you here is an example below

*********** Request For Estimate ***************
Name: Nicole Rutter
Address: 11124 my street
City: Omaha
State: Nebraska
Zip Code: 68154
Phone Number: 402-222-2222
Alternate Phone Number: 402-111-1111
Best Time to Call: Morning
Email Address: nicole@cfwebtools.com

Services Requested:
Flex

Website URL: nicole.cfwebtools.com

Message: Reqesting some information for a flex project

Happy coding!

Related Blog Entries

Comments
Nicole - You are a blessing to my little web world! Thanks for your selfless help! I tried your code, edited it a bit to my needs, and it works great!!

Thanks again! I truly appreciate it =)
# Posted By sime | 2/1/08 12:13 PM
Hi Nicole,

I'm not sure if you are a VB programmer (neither am I) but I'm trying to modify a code segment to relay mail thru my go-daddy email account rather that using gmail. I've modified the code below and tried port 80 and 3535 but it stops at the .send cmd. Any help would be appreciated:

My Code
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields


With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = 1

'.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = "mygmail@gmail.com"
'.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = "mypassword"
'.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = "smtp.gmail.com"
'.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = 2
'.Item("http://schemas.microsoft.com/cdo/configuration/smt...port" target="_blank">http://schemas.microsoft.com/cdo/configuration/smt...") = 465

.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = "myuser@mygodaddy.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = "mypassword"
.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = "smtpout.secureserver.net"
'.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = "relay-hosting.secureserver.net"
'.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = 2
'.Item("http://schemas.microsoft.com/cdo/configuration/smt...port" target="_blank">http://schemas.microsoft.com/cdo/configuration/smt...") = 3535
.Item("http://schemas.microsoft.com/cdo/configuration/smt...port" target="_blank">http://schemas.microsoft.com/cdo/configuration/smt...") = 80
.Update
End With


My code stops on the send command

Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = Email
.CC = ""
.BCC = ""
.From = """blah blah""<myuser@mygodaddy.com>"
.Subject = subj
.AddAttachment Attm
.TextBody = Msg
.Send
End With
Set iMsg = Nothing
# Posted By David Wright | 2/28/08 10:58 PM
I have the following code and it is working with most of the servers but i cannot get it work on ixwebhosting and i have received the following problem from the:

your messages have been discarded by our mail servers as non compatible with RFC. The messages have blank CC field (so, CC field presents, but it's blank).

and here is the code:

<%
form_from = "info@realitytravelguide.com"
form_to = "info@realitytravelguide.com"
form_cc = Request.Form("mail_cc")
form_bcc = Request.Form("mail_bcc")
form_subject = "Reality Form Submission"
form_importance = 1

FOR x = 1 TO Request.Form.Count
IF Request.Form.Key(x) = "mail_from" OR Request.Form.Key(x) = "mail_to" OR Request.Form.Key(x) = "mail_cc" OR Request.Form.Key(x) = "mail_bcc" OR Request.Form.Key(x) = "mail_subject" OR Request.Form.Key(x) = "mail_importance" OR Request.Form.Key(x) = "mail_redirect" OR Request.Form.Key(x) = "mail_send" OR Request.Form.Key(x) = "Submit" THEN
form_variables = form_variables
ELSE
form_variables = form_variables & Request.Form.Key(x) & ": " & vbcrlf & Request.Form.Item(x) & vbcrlf & vbcrlf
END IF
NEXT

DIM body_text
body_text = vbcrlf & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & vbcrlf
body_text = body_text & form_subject & vbcrlf
body_text = body_text & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & vbcrlf & vbcrlf
body_text = body_text & form_variables
body_text = body_text & "Sent from: " & vbcrlf & Request.ServerVariables("HTTP_REFERER") & vbcrlf & vbcrlf
body_text = body_text & "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & vbcrlf


<!--SET objMail = Server.CreateObject("CDONTS.NewMail")-->

SET objMail = CreateObject("CDO.Message")

<!--objMail.BodyFormat = 1-->
<!--objMail.MailFormat = 1-->

objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sen...")=2

objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smt...") _
="127.0.0.1"

objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smt...port" target="_blank">http://schemas.microsoft.com/cdo/configuration/smt...") _
=25
objMail.Configuration.Fields.Update


objMail.From = form_from
objMail.To = form_to
objMail.CC = form_cc
objMail.BCC = form_bcc
objMail.Subject = form_subject
<!--objMail.Importance = form_importance-->
objMail.TextBody = body_text
objMail.Send
SET objMail = NOTHING

Response.Write("")
%>

Can you please helm me where i am making it wrong?
# Posted By beyaz | 3/24/08 6:11 AM
Just curious, but did you try this with some test e-mails other than your own as the sender. For example, I came up with very similar code but it blows for anyone using AOL.COM as the from e-mail. So I had to send it from myself to myself and just put the e-mail into the message.

In other words, you might be missing e-mail and not even know it because your AOL user got an error.
# Posted By Matt Carpenter | 3/31/08 8:05 PM
I'm having trouble implementing your code on my godaddy site.

I built my site using M.S. web developer express 2008 using aspx pages and one of those pages is a reservation form which I need emailed to me.

As I couldn't get the code working within the aspx pages I created two pages exactly as you presented them above, only substituting my email address for:
"YOUR EMAIL ADDRESS" in the the form
and
myMail.To in the start_thanksN.asp


It seems no matter what I do, every time I click on the submit button I get the following error:

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

I know this is a long shot, but do you have any idea what resource is missing?
# Posted By Steve | 5/31/08 3:12 PM
As a follow up to my above post the name of the generic form is form.html, but I'd really like to get the proper reservation form working.

Thnaks for your help
# Posted By Steve | 5/31/08 4:44 PM
Can you tell me a little more about your set up. Is this by chance a DNN site? This sounds like a set up problem to me. Are you running an SSL on this site? You can send over your code if you want to and I can test it. I know the above code is working I just tested it to be sure.
# Posted By Nicole Rutter | 6/2/08 7:51 AM
Thanks for the code! One little thing I noticed (that gave me a hard time) is that the "from" email address needs to be from a domain apparently hosted with godaddy. When I first tried it with Nicole's "test@yahoo.com", it worked fine. As soon as I changed it to a different email address (a hotmail account), it errored. I then tried my client's email address (hosted on godaddy) and viola... worked again.
# Posted By marty | 6/4/08 9:51 AM



Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.