- Patch #359853 by jhodgdon: corrected and improved the documentation of hook_mail_alter().

merge-requests/26/head
Dries Buytaert 2009-06-27 10:19:31 +00:00
parent 77c643ec17
commit 9850918acf
1 changed files with 35 additions and 34 deletions

View File

@ -491,34 +491,32 @@ function hook_profile_alter(&$account) {
} }
/** /**
* Alter any aspect of the emails sent by Drupal. You can use this hook * Alter any aspect of email sent by Drupal. You can use this hook
* to add a common site footer to all outgoing emails; add extra header * to add a common site footer to all outgoing email, add extra header
* fields and/or modify the mails sent out in any way. HTML-izing the * fields, and/or modify the email in any way. HTML-izing the
* outgoing mails is one possibility. See also drupal_mail(). * outgoing email is one possibility. See also drupal_mail().
* *
* @param $message * @param $message
* A structured array containing the message to be altered. Keys in this * A structured array containing the message to be altered. Keys in this
* array include: * array include:
* mail_id * - 'id':
* An id to identify the mail sent. Look into the module source codes * An id to identify the mail sent. Look at module source code
* for possible mail_id values. * or drupal_mail() for possible id values.
* to * - 'to'
* The mail address or addresses where the message will be send to. The * The address or addresses the message will be sent to. The
* formatting of this string must comply with RFC 2822. * formatting of this string must comply with RFC 2822.
* subject * - 'subject'
* Subject of the e-mail to be sent. This must not contain any newline * Subject of the email to be sent. This must not contain any newline
* characters, or the mail may not be sent properly. * characters, or the email may not be sent properly.
* body * - 'body'
* An array of lines containing the message to be sent. Drupal will format * An array of lines containing the message to be sent. Drupal will format
* the correct line endings for you. * the correct line endings for you.
* from * - 'from'
* The From, Reply-To, Return-Path and Error-To headers in $headers * The address the message will be marked as being from, which is
* are already set to this value (if given). * either a custom address or the site-wide default email address.
* headers * - 'headers'
* Associative array containing the headers to add. This is typically * Associative array containing mail headers, such as From, Sender,
* used to add extra headers (From, Cc, and Bcc). * MIME-Version, Content-Type, etc.
* @return
* None.
*/ */
function hook_mail_alter(&$message) { function hook_mail_alter(&$message) {
if ($message['mail_id'] == 'my_message') { if ($message['mail_id'] == 'my_message') {
@ -852,33 +850,36 @@ function hook_watchdog(array $log_entry) {
} }
/** /**
* Prepare a message based on parameters. @see drupal_mail for more. * Prepare a message based on parameters; called from drupal_mail().
* *
* @param $key * @param $key
* An identifier of the mail. * An identifier of the mail.
* @param $message * @param $message
* An array to be filled in. Keys in this array include: * An array to be filled in. Keys in this array include:
* - 'mail_id': * - 'id':
* An id to identify the mail sent. Look into the module source codes * An id to identify the mail sent. Look at module source code
* for possible mail_id values. * or drupal_mail() for possible id values.
* - 'to': * - 'to':
* The mail address or addresses where the message will be send to. The * The address or addresses the message will be sent to. The
* formatting of this string must comply with RFC 2822. * formatting of this string must comply with RFC 2822.
* - 'subject': * - 'subject':
* Subject of the e-mail to be sent. This must not contain any newline * Subject of the e-mail to be sent. This must not contain any newline
* characters, or the mail may not be sent properly. Empty string when * characters, or the mail may not be sent properly. drupal_mail() sets
* the hook is invoked. * this to an empty string when the hook is invoked.
* - 'body': * - 'body':
* An array of lines containing the message to be sent. Drupal will format * An array of lines containing the message to be sent. Drupal will format
* the correct line endings for you. Empty array when the hook is invoked. * the correct line endings for you. drupal_mail() sets this to an empty
* array when the hook is invoked.
* - 'from': * - 'from':
* The From, Reply-To, Return-Path and Error-To headers in $headers * The address the message will be marked as being from, which is
* are already set to this value (if given). * set by drupal_mail() to either a custom address or the site-wide
* default email address when the hook is invoked.
* - 'headers': * - 'headers':
* Associative array containing the headers to add. This is typically * Associative array containing mail headers, such as From, Sender,
* used to add extra headers (From, Cc, and Bcc). * MIME-Version, Content-Type, etc. drupal_mail() pre-fills
* several headers in this array.
* @param $params * @param $params
* An arbitrary array of parameters set by the caller to drupal_mail. * An array of parameters supplied by the caller of drupal_mail().
*/ */
function hook_mail($key, &$message, $params) { function hook_mail($key, &$message, $params) {
$account = $params['account']; $account = $params['account'];