You are here

Example: Email in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 email_example/email_example.module \email_example
  2. 6 email_example/email_example.module \email_example
  3. 7 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 MailManager::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.

File

modules/email_example/email_example.module, line 10
Example of how to use Drupal's mail API.

Functions

Namesort descending Location Description
email_example_mail modules/email_example/email_example.module Implements hook_mail().
email_example_mail_alter modules/email_example/email_example.module Implements hook_mail_alter().

Classes

Namesort descending Location Description
EmailExampleGetFormPage modules/email_example/src/Form/EmailExampleGetFormPage.php File test form class.
EmailExampleTest modules/email_example/tests/src/Functional/EmailExampleTest.php Tests for the email_example module.