Contact Me

  • Tags: contact, email
  • Latest: 0.2.1
  • Last Updated: 14 August 2009
  • Grails version: 1.1 >*
  • Authors: null
1 vote
Dependency:
compile ":contact-me:0.2.1"

 Documentation

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.

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 plugin

If 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 email

from: ${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 question

Hooks

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() } }

Here is the definition of the mail form command class (can be found in ContactMeController):

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
To see this plugin in action, go to: http://smartwebsystems.biz/sws/contact.gsp

For any enhancements or questions, please feel free to contact me at scott at bulldoginfo dot com