Skip to main content
Participating Frequently
July 28, 2008
Question

ColdFusion contact form by email - please help

  • July 28, 2008
  • 1 reply
  • 590 views
Hello,

I tried to create a contact form, using email to send, and I have some issues and questions:

1. I like to have a message "Your form has been sent", but it shows the blank after user submited the form.
2. If user enter her email address, this form will send to her email address and me, but it does not send to her email address.

Can anyone please take a look at my code below?
Why I don't get the output (result) I like to have?

Thanks very much.

Jenny.

<cfif IsDefined("form.Subject")>
<cfprocessingdirective suppresswhitespace="no">
<cfmail subject="#form.Subject#" from="#form.From#" to="test@test.com" >
This is a message from that form...
#form.Message#
</cfmail>
</cfprocessingdirective>
<cfelse>

<cfform action="#CGI.SCRIPT_NAME#" method="post" name="frmName">
name <cfinput type="text" name="Name" size="20"><br />
email <cfinput type="text" name="Email" size="20"><br />
Subject <cfinput type="text" name="Subject" size="20"><br />
Message <textarea name="Message" cols="30" rows="3" ></textarea><br />
<input type="submit" value="Submit it" />
</cfform>

<cfif isDefined("FORM.Name")>
<cfmail subject="#form.Subject#" from="#form.From#" to="#Email#" >
</cfif>

<cfif isDefined("FORM.Submit")>
<p>Your message has been sent</p>
<cfelse>
<cflocation addtoken="no" url="survey2.cfm">
</cfif>
    This topic has been closed for replies.

    1 reply

    Inspiring
    July 28, 2008
    I always start my troubleshooting with
    <cfdump var="#form#">
    <cfabort>

    You also have a problem with an cfmail tag without the closing tag. I'm surprised that didn't cause a crash.

    You also have some problems with your if/else logic.