class Messaging_HTML_Mail_Method in Messaging 7
Base class for mail sending methods
Hierarchy
- class \Messaging_Mail_Method extends \Messaging_Send_Method
- class \Messaging_HTML_Mail_Method
Expanded class hierarchy of Messaging_HTML_Mail_Method
1 string reference to 'Messaging_HTML_Mail_Method'
- messaging_htmlmail_messaging in messaging_htmlmail/
messaging_htmlmail.module - Implementation of hook_messaging()
File
- messaging_htmlmail/
messaging_htmlmail.inc, line 10 - Drupal Messaging Framework - Send_Method class file
View source
class Messaging_HTML_Mail_Method extends Messaging_Mail_Method {
// Default group and address type
public $method = 'mimemail';
public $type = 'mail';
public $anonymous = TRUE;
public $format = MESSAGING_FORMAT_HTML;
// Mail system object to create it only once and reuse
protected static $mail_system;
/**
* Rebuild message in Drupal mail format, right before sending
*
* Note that our 'body' element is a renderable array, not like drupal_mail()
* This may clash with some module altering the mail
*
* This mimics drupal_mail for finest access to properties
* @param $address
* Email address to send to
* @param $message
* Message object
*/
protected function mail_build($address, $message) {
$params = $this
->message_params($message);
$template = $message
->get_template();
$mail = array(
'headers' => $this
->mail_headers($message, $params),
'id' => $message->module . '_' . $message->key,
'module' => $message->module,
'key' => $message->key,
'to' => $params['send_bcc'] ? '' : $address,
'from' => isset($params['from']) ? $params['from'] : $params['default_from'],
'language' => $message
->get_language(),
'params' => $params,
'subject' => $message
->get_subject(),
// Bundle up the variables into a structured array for altering.
'body' => $template
->set_format(MESSAGING_FORMAT_HTML)
->build('body'),
'body_plain' => $template
->set_format(MESSAGING_FORMAT_PLAIN)
->render('body'),
'attachments' => $message
->get_files(),
);
if ($params['send_bcc']) {
$mail['headers']['Bcc'] = $address;
}
// Build the e-mail (get subject and body, allow additional headers) by
// invoking hook_mail() on this module. We cannot use module_invoke() as
// we need to have $message by reference in hook_mail().
if (function_exists($function = $message->module . '_mail')) {
$function($message->key, $mail, $params);
}
// Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail.
drupal_alter('mail', $mail);
// Invoke drupal_mail without sending, then override headers
return $mail;
}
/**
* Actually send mail through Drupal system
*
* @param $mail
* Built Drupal mail array, not rendered
* @param $message
* Original message object
*/
protected static function mail_send($mail, $message) {
// Retrieve the responsible implementation for this message.
//$system = drupal_mail_system($mail['module'], $mail['key']);
if (!isset(self::$mail_system)) {
self::$mail_system = new Messaging_HTML_MailSystem();
}
// Format the message body, last chance for formatting
$mail = self::$mail_system
->format($mail);
return self::$mail_system
->mail($mail);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Messaging_HTML_Mail_Method:: |
public | property |
Overrides Messaging_Mail_Method:: |
|
Messaging_HTML_Mail_Method:: |
public | property |
Overrides Messaging_Mail_Method:: |
|
Messaging_HTML_Mail_Method:: |
protected static | property | ||
Messaging_HTML_Mail_Method:: |
public | property |
Overrides Messaging_Mail_Method:: |
|
Messaging_HTML_Mail_Method:: |
public | property |
Overrides Messaging_Mail_Method:: |
|
Messaging_HTML_Mail_Method:: |
protected | function |
Rebuild message in Drupal mail format, right before sending Overrides Messaging_Mail_Method:: |
|
Messaging_HTML_Mail_Method:: |
protected static | function |
Actually send mail through Drupal system Overrides Messaging_Mail_Method:: |
|
Messaging_Mail_Method:: |
public static | function | Get address type | |
Messaging_Mail_Method:: |
static | function | Get default method parameters, not depending on message | |
Messaging_Mail_Method:: |
static | function | Format from name and address | |
Messaging_Mail_Method:: |
static | function | Get mail headers. Helper function for mail methods | |
Messaging_Mail_Method:: |
protected | function | Prepare from address and mail headers | |
Messaging_Mail_Method:: |
function | Get message parameters for this method. | ||
Messaging_Mail_Method:: |
function | Add specific mail parameters to message | ||
Messaging_Mail_Method:: |
function | Render message body. This will produce an array of lines to be formatted later | ||
Messaging_Mail_Method:: |
function | Send message to address |