Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Cfmail processing error - what's wrong with my code?

New Here ,
May 08, 2009 May 08, 2009

Hi Everybody,

I am not a tech person but I'll try my best describing the situation.

When I yesterday tried to fix an error message (which always showed when not all requiered fields were filled in at our company's "Request for Quote" site), I think I messed up the whole inquiry-forwarding system. I must have deleted everything.

My company's using Macromedia Dreamwaver 8, and the guy who wrote the pages are long gone. If only I could revert the present non-functioning system how it used to be but it's too late, I already turned my comp off yesterday.

The way it should work is that the customer types in all info we need from him, then pushes the submit button, which then sends an email to us and leads the customer to our "Thank you for your inquiry" page. If some eror happens, it brings the customer to our mailto.cfm page, which now shows some error message I do not understand about the 3rd line, 

variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"RECIPIENT") );

Here's what I found as an old-timer back-up to our mailto.cfm page (which I altered yesterday, and that caused the whole problem), which no longer works either:

<cfscript>
    variable.fieldnames = form.fieldnames;
    variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"RECIPIENT") );
    variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"SUBJECT") );
    variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"THANKURL") );
</cfscript>
<cfparam name="FORM.SUBJECT" default="Web Site Form">
<cfmail to="ouremail@ourdomain.com" from="inforequest@ourdomain.com" subject="#FORM.SUBJECT#">#FORM.SUBJECT#
Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')#

<cfloop index="i" list="#variable.fieldnames#"><cfif len(evaluate("form.#i#"))><cfif uCase(right(i,6)) eq "_BREAK">#chr(13)#</cfif>#ReplaceNoCase(i,"_BREAK","")#:#RepeatString(" ", evaluate(15-len(ReplaceNoCase(i,"_BREAK",""))))# #Replace( evaluate("form.#i#"), chr(10), chr(10) & RepeatString(" ",17), "All" )# #chr(13)#</cfif></cfloop>
</cfmail>

<cflocation url="#form.THANKURL#" addtoken="No">

It seems simple, the to-field is correct, the from-field must be too, why do you still think that it's not forwarding the inquiries as emails any more? Where is this code broken?

I would welcome all suggestions, I really need your help!

5.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , May 13, 2009 May 13, 2009

Ok this is wierd, but your system does not seem to be accepting the line returns in the code.  That is not normal behavior.  But you can hard code them in.

Out of curisoity what type of systems are you working with?

<cfmail
   to="julianna@airengineering.com"
   from="#form.email#"
   subject="#FORM.SUBJECT#">

#FORM.SUBJECT#

Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')##chr(13)##chr(10)#

<cfloop list="#form.fieldnames#" index="field">
<cfif listFindNoCase("RECIPIENT,SUBJECT
...
Translate
Valorous Hero ,
May 13, 2009 May 13, 2009

Julianna01 wrote:

Yes, I can. I copy the content of the email, create the box, then paste the email into it.

Make sure you are using the "Plain" version, I have had wierd problems with the other choices.

I will figure out how I could put an extra line below the date, so it's easier to read, but that's just some esthatical thing.

The #chr(13)##chr(10)# functions are creating the carriage return|line feeds for your output.  Just put a set of those every where you want another one.

However, what I found I would definitely need to consult you on is if you have an idea how I could add required fields. Right now anybody who punches in an email address can spam us, and I would need to protect our box so we only receive those inquiries that do contain first-last name, title, city, state etc., a few fields, not all obvoiusly. Any idea?

Ok that is a whole other topic that can be as long or longer then this current one.  Where do you want the validation client or server.  What do you want to happen when validation fails.  ColdFusion has several form validation features built in as well as there are many frameworks that provide validation or one can always roll ones own version.

The ColdFusion Developers Guide included with the ColdFusion documentation has an entire chapter on validation.  It is a good place to start.

http://livedocs.adobe.com/coldfusion/8/htmldocs/validateData_01.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 13, 2009 May 13, 2009
LATEST

Ian,

Thanks soo much for your help! The code is working now, I will figure out a way to add the required fields, thanks for your input on that, too. Will return to this business as soon as I will have some more time, but we poured the water on the fire with just this much. Again, I really appreciate it, you were a real rescuer!!

Have a great day,

Julianna

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 13, 2009 May 13, 2009

Ok this is wierd, but your system does not seem to be accepting the line returns in the code.  That is not normal behavior.  But you can hard code them in.

Out of curisoity what type of systems are you working with?

<cfmail
   to="julianna@airengineering.com"
   from="#form.email#"
   subject="#FORM.SUBJECT#">

#FORM.SUBJECT#

Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')##chr(13)##chr(10)#

<cfloop list="#form.fieldnames#" index="field">
<cfif listFindNoCase("RECIPIENT,SUBJECT,THANKURL",field) EQ 0><cfif len(trim(form[field])) GT 0>#repeatString(" ",20-len(replaceNoCase(field,"_BREAK","")))#
#replaceNoCase(field,"_BREAK","")#:#replace(form[field],chr(10),chr(10 ) & repeatString(" ",17),"ALL")##chr(13)##chr(10)#
</cfif></cfif>
</cfloop>
</cfmail>

<cflocation url="#form.THANKURL#" addtoken="No">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources