[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/includes/ -> mail.inc (summary)

(no description)

File Size: 480 lines (18 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 8 functions

  drupal_mail()
  drupal_mail_send()
  drupal_wrap_mail()
  drupal_html_to_text()
  _drupal_wrap_mail_line()
  _drupal_html_to_mail_urls()
  _drupal_html_to_text_clean()
  _drupal_html_to_text_pad()

Functions
Functions that are not part of a class:

drupal_mail($module, $key, $to, $language, $params = array()   X-Ref
Compose and optionally send an e-mail message.

Sending an e-mail works with defining an e-mail template (subject, text
and possibly e-mail headers) and the replacement values to use in the
appropriate places in the template. Processed e-mail templates are
requested from hook_mail() from the module sending the e-mail. Any module
can modify the composed e-mail message array using hook_mail_alter().
Finally drupal_mail_send() sends the e-mail, which can be reused
if the exact same composed e-mail is to be sent to multiple recipients.

Finding out what language to send the e-mail with needs some consideration.
If you send e-mail to a user, her preferred language should be fine, so
use user_preferred_language(). If you send email based on form values
filled on the page, there are two additional choices if you are not
sending the e-mail to a user on the site. You can either use the language
used to generate the page ($language global variable) or the site default
language. See language_default(). The former is good if sending e-mail to
the person filling the form, the later is good if you send e-mail to an
address previously set up (like contact addresses in a contact form).

Taking care of always using the proper language is even more important
when sending e-mails in a row to multiple users. Hook_mail() abstracts
whether the mail text comes from an administrator setting or is
static in the source code. It should also deal with common mail tokens,
only receiving $params which are unique to the actual e-mail at hand.

An example:

param: $module
param: $key
param: $to
param: $language
param: $params
param: $from
param: $send
return:

drupal_mail_send($message)   X-Ref
Send an e-mail message, using Drupal variables and default settings.
More information in the <a href="http://php.net/manual/en/function.mail.php">
PHP function reference for mail()</a>. See drupal_mail() for information on
how $message is composed.

param: $message
return:

drupal_wrap_mail($text, $indent = '')   X-Ref
Perform format=flowed soft wrapping for mail (RFC 3676).

We use delsp=yes wrapping, but only break non-spaced languages when
absolutely necessary to avoid compatibility issues.

We deliberately use LF rather than CRLF, see drupal_mail().

param: $text
param: $indent (optional)

drupal_html_to_text($string, $allowed_tags = NULL)   X-Ref
Transform an HTML string into plain text, preserving the structure of the
markup. Useful for preparing the body of a node to be sent by e-mail.

The output will be suitable for use as 'format=flowed; delsp=yes' text
(RFC 3676) and can be passed directly to drupal_mail() for sending.

We deliberately use LF rather than CRLF, see drupal_mail().

This function provides suitable alternatives for the following tags:
<a> <em> <i> <strong> <b> <br> <p> <blockquote> <ul> <ol> <li> <dl> <dt>
<dd> <h1> <h2> <h3> <h4> <h5> <h6> <hr>

param: $string
param: $allowed_tags (optional)
return:

_drupal_wrap_mail_line(&$line, $key, $values)   X-Ref
Helper function for array_walk in drupal_wrap_mail().

Wraps words on a single line.

_drupal_html_to_mail_urls($match = NULL, $reset = FALSE)   X-Ref
Helper function for drupal_html_to_text().

Keeps track of URLs and replaces them with placeholder tokens.

_drupal_html_to_text_clean($indent)   X-Ref
Helper function for drupal_wrap_mail() and drupal_html_to_text().

Replace all non-quotation markers from a given piece of indentation with spaces.

_drupal_html_to_text_pad($text, $pad, $prefix = '')   X-Ref
Helper function for drupal_html_to_text().

Pad the last line with the given character.



Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7