Contact Me
Dependency :
compile ":contact-me:0.2.1"
Summary
Installation
grails install-plugin contact-me
Description
Provides a simple AJAX contact me form. Uses the mail plugin to send a email based on form entries. A simple captcha challenge is used to validate the user.Here is the definition of the mail form command class (can be found in ContactMeController):
Configuration options (in Config.groovy)
- contactme.to.address: The destination email address (required)
- contactme.email.view: An alternative view to use to format the email
- contactme.form.view: An alternative view for the contact form
- contactme.thanks.view: An alternative view after the email is sent
The contact-me plugin uses the form-helper plugin to make styling easier. If you need additional information on the <form:xxx> tags, see the form-helper pluginIf you place additional fields in the contact form, those are available in the params variable to all other views
Configuration options for the Mail Plugin also apply.
Here is the default view
<%@ page contentType="text/plain"%>
You have a contact-me emailfrom: ${contactForm.name}
at: ${contactForm.email}
subject: ${contactForm.subject}-----------------------------------------------------${contactForm.message}Tags
<cm:form>
Displays the contact me form<cm:captchaRequest>
Used in the form to place the captcha challenge questionHooks
afterContactMe
You can perform some action after the mail is sent using properties from the form used by the contactMe controller.To do this simply define a 'afterContactMe' closure in any artefact class. Here is an example that writes a log entry after a email is sent.class MailLog { Date dateCreated
String name
String email
String subject
String message static afterContactMe = { form, params ->
new MailLog(name:form.name, email:form.email, subject:form.subject, message:form.message).save()
}
}class ContactForm {
String name
String email
String subject
String message
String captcha static constraints = {
name(blank: false)
email(blank: false, email: true)
subject(blank: false)
message(blank: false)
}
}Future enhancements
- Image based captcha