Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active February 20, 2024 14:33
Show Gist options
  • Save stevewithington/8314e97d136ad23769de to your computer and use it in GitHub Desktop.
Save stevewithington/8314e97d136ad23769de to your computer and use it in GitHub Desktop.
Mura CMS : How to send an email to the person who submitted the form
<!--- Drop this in your Site or Theme eventHandler.cfc --->
<cffunction name="onAfterFormSubmitSave">
<cfargument name="$">
<cfset var msg = '' />
<cfset var formBean = $.event().getValue('formBean') />
<cfset var formResultBean = $.event().getValue('formDataBean') />
<cfset var formResultStruct = $.event().getValue('formDataBean').getValue('formResult') />
<cfif formBean.getTitle() eq 'Your Desired Form Title'>
<cfsavecontent variable="msg">
<!--- this assumes your form had a 'name' form field --->
<cfoutput>
<p>Hello #formResultBean.getValue('name')#,</p>
<p>Thank you for submitting a form!</p>
<p>Cheers,<br>
The Mura Team</p>
</cfoutput>
</cfsavecontent>
<!--- assumes your form had a 'emailFrom' field that collected the 'from' email --->
<cfset $.getBean('mailer').sendHTML(
html=msg
, sendto=formResultBean.getValue('emailFrom')
, from=formResultBean.getValue('emailFrom')
, subject='Your Subject'
, siteid=$.event('siteid')
, replyTo=formResultBean.getValue('emailFrom')
) />
</cfif>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment