hook_mail_alter

  1. drupal
    1. drupal6
    2. drupal7 system.api.php
Versionen
drupal6 – drupal7 hook_mail_alter(&$message)

Alter any aspect of email sent by Drupal. You can use this hook to add a common site footer to all outgoing email, add extra header fields, and/or modify the email in any way. HTML-izing the outgoing email is one possibility. See also drupal_mail().

Übergabeparameter

$message A structured array containing the message to be altered. Keys in this array include:

  • 'id' An id to identify the mail sent. Look at module source code or drupal_mail() for possible id values.
  • 'to' The mail address or addresses the message will be sent to. The formatting of this string must comply with RFC 2822.
  • 'subject' Subject of the e-mail to be sent. This must not contain any newline characters, or the mail may not be sent properly.
  • 'body' An array of lines containing the message to be sent. Drupal will format the correct line endings for you.
  • 'from' The address the message will be marked as being from, which is either a custom address or the site-wide default email address.
  • 'headers' Associative array containing mail headers, such as From, Sender, MIME-Version, Content-Type, etc.
  • 'params' An array of optional parameters supplied by the caller of drupal_mail() that is used to build the message before hook_mail_alter() is invoked.
  • language' The language object used to build the message before hook_mail_alter() is invoked.

Verwandte Themen

Code

developer-docs/hooks/core.php, line 1098

<?php
function hook_mail_alter(&$message) {
  if ($message['id'] == 'modulename_messagekey') {
    $message['body'][] = "--\nMail sent out from " . variable_get('sitename', t('Drupal'));
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen