When you create a form in Mura CMS, there are a couple of convenient fields available. One field allows for a comma-separated list of email addresses to receive notification whenever the form is submitted. Another field is a text area for displaying a "confirmation message" to the person who submits the form.
One field that isn't currently available is a checkbox to "send copy to submitter." A good reason for this could simply be that since a form could contain any number of unique fields and field names, it could be very difficult to programmatically allow for something as unique as this.
So I wrote a simple custom display object that will essentially check for a form field called "email" and if it is valid, send a confirmation message to the submitter (assuming the submitter's email is contained within the "email" form field). Lost yet? I hope not.
First, you'll want to create a custom display object. you can copy the code below and save it to/as "[siteid]/includes/display_objects/custom/dsp_email_confirmation.cfm"
Author: Steve Withington | www.stephenwithington.com
Purpose: I send email confirmations to form submitters.
Instructions: Assuming you've placed this file in/as:
Go to "Forms" in your admin, select the form you want to use this script
in, go to the "Confirmation Message" text area, then copy + paste this:
This could be the only line of text in your Confirmation Message text area
since now you can modify the confirmation text below. However, any
text in the "Confirmation Message" form field will also be display on
The confirmationText below can even be a dynamic field that's passed in
on form submission, etc.
<cfoutput>Thank you for for your inquiry. A representative will contact you shortly. For immediate assistance, feel free to call 800.555.1212.</cfoutput>
<cfif structKeyExists(request, "email") and isValid("email", request.email)>
<cfset site = application.settingsManager.getSite(request.siteID) />
<cfset success=true />
<cfset email=application.serviceFactory.getBean('mailer') />
<cfset email.sendText(confirmationText, form.email, form.email, site.getSite(), request.siteid, form.email) />
<cfset success=false />
<!--- if successful, a confirmation message can be displayed here --->
<p class="success"><em>A confirmation has also been sent to your email.</em></p>
<!--- if an error occurs, an error message can be displayed here --->
<p class="error">Sorry, we experienced a problem in our attempt to send you a confirmation via email.</p>
<!--- you can display an error message if the email address provided is not valid --->
<p class="error">Unfortunately, the email address you provided was not a valid email address.</p>
Next, you'll want to go to your "Forms" section in your admin area, select the form you want to use this script in, go to the "Confirmation Message" text area, then copy and past this in:
You can then simply modify the confirmation message within the script, or even pass one in dynamically.
Hope this helps!