Example: Email

Same name in other branches
  1. 3.x modules/email_example/email_example.module \email_example
  2. 8.x-1.x email_example/email_example.module \email_example
  3. 6.x-1.x email_example/email_example.module \email_example
  4. 4.0.x modules/email_example/email_example.module \email_example

Example of how to use Drupal's mail API.

This example module provides two different examples of the Drupal email API:

  • Defines a simple contact form and shows how to use drupal_mail() to send an e-mail (defined in hook_mail()) when the form is submitted.
  • Shows how modules can alter emails defined by other Drupal modules or Core using hook_mail_alter by attaching a custom signature before they are sent.

Parent topics

File

email_example/email_example.module, line 7

Functions

Title Sort descending File name Summary
email_example_form email_example/email_example.module The contact form.
email_example_form_submit email_example/email_example.module Form submission logic for the contact form.
email_example_form_validate email_example/email_example.module Form validation logic for the contact form.
email_example_mail email_example/email_example.module Implements hook_mail().
email_example_mail_alter email_example/email_example.module Implements hook_mail_alter().
email_example_mail_send email_example/email_example.module Sends an e-mail.
email_example_menu email_example/email_example.module Implements hook_menu().

Classes

Title Sort descending File name Summary
EmailExampleTestCase email_example/email_example.test Functionality tests for email example module.