Install

Using Composer to manage Drupal site dependencies

Alternative installation files

Download tar.gz 17.84 KB
MD5: ed6ab99ed809544da566a8f817f9c4d5
SHA-1: 757bde5ae68e431f4fb2d14049e26ba160691657
SHA-256: a9198bfaf1dac263408d01517bad4a31da284061fb5e8853afde861b4f5184d4
Download zip 20.9 KB
MD5: d4e7a1ab0a2d8f0644b557afb3319042
SHA-1: 227a6f53f73691d2c0be67d8de8d2a3f7e364f2b
SHA-256: 635873cf1ba1bcc208f602a5ef033070bbbe5dbc68e6d6f8213b4f62d40b14fb

Release notes

Minor line-wrapping improvements:
#1172996-7: Track recent changes in #299138

Mail System

Provides an Administrative UI and Developers API for safely updating the mail_system configuration variable.

Administrative UI

The administrative interface is at admin/config/system/mailsystem. A screenshot is available.

Used by;

Developers API

A module example with a MailSystemInterface implementation called ExampleMailSystem should add the following in its example.install file:

/**
 * Implements hook_enable().
 */
function example_enable() {
  mailsystem_set(array('example' => 'ExampleMailSystem'));
}
/**
 * Implements hook_disable().
 */
function example_disable() {
  mailsystem_clear(array('example' => 'ExampleMailSystem'));
}

The above settings allow mail sent by example to use ExampleMailSystem. To make ExampleMailSystem the site-wide default for sending mail:

mailsystem_set(array(mailsystem_default_id() => 'ExampleMailSystem'));

To restore the default mail system:

mailsystem_set(array(mailsystem_default_id() => mailsystem_default_value()));

Or simply:

mailsystem_set(mailsystem_defaults());

If module example relies on dependency foo and its FooMailSystem class, then the example.install code should like like this:

/**
 * Implements hook_enable().
 */
function example_enable() {
  mailsystem_set(array('example' => 'FooMailSystem'));
}
/**
 * Implements hook_disable().
 */
function example_disable() {
  mailsystem_clear(array('example' => ''));
}

If module example only wants to use FooMailSystem when sending emails with a key of examail, then the example.install code should look like this:

/**
 * Implements hook_enable().
 */
function example_enable() {
  mailsystem_set(array('example_examail' => 'FooMailSystem'));
}
/**
 * Implements hook_disable().
 */
function example_disable() {
  mailsystem_clear(array('example_examail' => ''));
}

(New in 2.x branch)

To change the site-wide defaults to use the FooMailSystem for formatting messages and the BarMailSystem for sending them:

mailsystem_set(
  array(
    mailsystem_default_id() => array(
      'format' => 'FooMailSystem',
      'mail' => 'BarMailSystem',
    ),
  )
);

To change the site-wide defaults to use the FooMailSystem for sending messages, while continuing to use the current system for formatting them:

mailsystem_set(
  array(
    mailsystem_default_id() => array(
      'mail' => 'FooMailsystem',
    ),
  )
);

References

drupal_mail_system() API documentation:

api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail_system

MailSystemInterface API documentation:

api.drupal.org/api/drupal/includes--mail.inc/interface/MailSystemInterface

Creating HTML formatted mails in Drupal 7

drupal.org/node/900794

Created by: pillarsdotnet
Created on: 4 Jun 2011 at 21:48 UTC
Last updated: 4 Jun 2011 at 21:51 UTC
Bug fixes
Unsupported

Other releases