Marion Newlevant: Web Developer

A software craftswoman in Portland, Oregon with a thing for clean code...

fork on github download .zip download .tgz

Simple_mail

E-mail sending plugin. In the usual way, we have a form which posts back to the same page, so the first thing is to check whether the form has been filled in and is valid. If so, send the e-mail, and display the confirmation. If not, display the form (including any validation errors).

Example

{exp:simple_mail:send recipient="recipient@sample.com"}

{if "{exp:simple_mail:sent}"}
  <p>Thank You</p>
{if:else}
  <div class="error">{exp:simple_mail:validation_errors}</div>
  <form method="post">
    <input type="email" name="email" value="" id="email"  />
    <select name="subject" id="subject">
      <option value="just hi">just hi</option>
    </select>
    <textarea name="message" id="message"></textarea><br/><br/>
    <input type="submit" value="submit"/>
  </form>
{/if}

Details

The form action should post back to the same page. Form fields are:

Tags:

exp:simple_mail:send - parameter: recipient
at top of page: will send the e-mail if the form is filled in.
exp:simple_mail:sent
was the mail sent? boolean
exp:simple_mail:validation_errors
possibly empty list of <p> formatted form errors

Notes

I wrote this plugin so that I could send e-mail from a form in EE sites that use the Core license (which doesn’t include the e-mail module). It is a fairly thin layer on top of CodeIgniter email.

Limitations: