O'Reilly logo

Drupal 7 Module Development by Ken Rickard, John Wilkins, Larry Garfield, Matt Butcher, Greg Dunlap, Matt Farina

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending mail with drupal_mail() and hook_mail()

Drupal implements a custom e-mail templating system. Initially it may appear that this system is overly complicated, but it allows an enormous amount of flexibility for module developers.

Sending e-mail in Drupal is a multi-step process:

  1. drupal_mail() is called, specifying what mail is being sent and what options are unique to this specific message (the recipient's e-mail address, the language the mail should be sent in, and so on).
  2. Drupal then builds an e-mail message with standard headers combined with the information submitted to drupal_mail().
  3. The hook_mail() implementation specified in drupal_mail() is called. This is where the subject and body of the mail are added.
  4. The fully composed mail array ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required