I've set up an email form (with a captcha) that will submit an email to a
seller on my website. The "TO" attribute is simply a query variable. But for
some reason, I keep getting the following error.
"Attribute validation error for tag CFMAIL. The value of the attribute TO is
invalid. The length of the string, 0 character(s), must be greater than or
equal to 1."
I use a <cfdump> and it alwsys returns a valid email address, so I can't figure
out why the <cfmail> thinks the TO field is empty.
Below is my code. Thanks in advance. Rick
-----------------------------------------------------------------------------------
<cfparam name="URL.ProdID" default="" >
<cfquery name="getproducts" datasource="DB">
SELECT ProdID, Email
FROM Products P
JOIN Users U
ON P.UserID = U.UserID
WHERE P.ProdID = <cfqueryparam value="#Val(URL.ProdID)#"
cfsqltype="cf_sql_integer" maxlength="4">
</cfquery>
<cfset sendEmail = #getproducts.Email#>
<cfdump var="#sendEmail#">
<!--- create captcha --->
<cfif not structKeyExists(application, "captcha")>
<cfset application.captcha = createObject("component",
"captchaService").init(configFile="captcha.xml") />
<cfset application.captcha.setup()>
</cfif>
<cfparam name="form.name" default="">
<cfparam name="form.email" default="">
<cfparam name="form.comments" default="">
<cfparam name="form.phone" default="">
<cfset showForm = true>
<cfif structKeyExists(form, "sendcomments")>
<cfset error = "">
<cfif not len(trim(form.name))>
<cfset error = error & "Please include your name.<br>">
</cfif>
<cfif not len(trim(form.email)) or not isValid("email", form.email)>
<cfset error = error & "Please include a valid email
address.<br>">
</cfif>
<!---cfif not len(trim(form.comments))>
<cfset error = error & "It's called a Comment Form,
stupid.<br>">
</cfif--->
<cfif not application.captcha.validateCaptcha(form.hash, form.captcha)>
<cfset error = error & "You did not match the image text.
Please try again.<br>">
</cfif>
<cfif error is "">
<cfmail to="#sendEmail#" bcc="[EMAIL PROTECTED]" from="[EMAIL
PROTECTED]" subject="I'm interested in your dress on WoreItOnce.com"
server="mail.domain.com" >
From: #form.name# (#form.email#)
Phone: #form.phone#
Comments:
#form.comments#
</cfmail>
<cfset showForm = false>
</cfif>
</cfif>
<cfif showForm>
<cfif structKeyExists(variables, "error")>
<cfoutput>
<p>
<b>Please correct these errors:<br>
#error#
</b>
</p>
</cfoutput>
</cfif>
<cfoutput>
<form action="test2.cfm" method="post">
<table>
<tr>
<td>Your Name:<br />
<input type="text" name="name" value="#form.name#"></td>
</tr>
<tr>
<td>Your Email:<br />
<input type="text" name="email"
value="#form.email#"></td>
</tr>
<tr>
<td>Your Phone:<br />
<input name="phone" type="text" id="phone"
value="#form.phone#"></td>
</tr>
<tr>
<td>Your Comments:<br />
<textarea
name="comments">#form.comments#</textarea></td>
</tr>
<tr>
<td>Enter Text Shown in Picture:<br />
<input type="text" name="captcha"><br>
<!--- Captcha --->
<cfset captcha =
application.captcha.createHashReference()>
<img src="captcha.cfm?hash=#captcha.hash#">
<input name="hash" type="hidden" value="#captcha.hash#"
/> </td>
</tr>
<tr>
<td>
<input type="submit" name="sendcomments" value="Send
Comments"></td>
</tr>
</table>
</form>
</cfoutput>
<cfelse>
<cfoutput>
<p>
Thank you for sending your comments, #form.name#.
</p>
</cfoutput>
</cfif>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:308398
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4