You are here

class UserImportMailSystem in User Import 7.3

Same name and namespace in other branches
  1. 7.2 user_import.module \UserImportMailSystem

Modify the drupal mail system to send HTML emails.

See http://drupal.org/node/900794.

Hierarchy

Expanded class hierarchy of UserImportMailSystem

2 string references to 'UserImportMailSystem'
user_import_install in ./user_import.install
Implementation of hook_install().
user_import_update_7201 in ./user_import.install
Add a new mail system for HTML emails.

File

./user_import.module, line 894
Import or update users with data from a comma separated file (csv).

View source
class UserImportMailSystem implements MailSystemInterface {

  /**
   * Concatenate and wrap the e-mail body.
   *
   * @param $message
   *   A message array, as described in hook_mail_alter().
   *
   * @return
   *   The formatted $message.
   */
  public function format(array $message) {
    $message['body'] = implode("\n\n", $message['body']);
    return $message;
  }

  /**
   * Send an e-mail message, using Drupal variables and default settings.
   *
   * @see <a href="http://php.net/manual/en/function.mail.php
   * " title="http://php.net/manual/en/function.mail.php
   * " rel="nofollow">http://php.net/manual/en/function.mail.php
   * </a>   * @see drupal_mail()
   *
   * @param $message
   *   A message array, as described in hook_mail_alter().
   * @return
   *   TRUE if the mail was successfully accepted, otherwise FALSE.
   */
  public function mail(array $message) {
    $mimeheaders = array();
    foreach ($message['headers'] as $name => $value) {
      $mimeheaders[] = $name . ': ' . mime_header_encode($value);
    }
    $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
    return mail($message['to'], mime_header_encode($message['subject']), preg_replace('@\\r?\\n@', $line_endings, $message['body']), join("\n", $mimeheaders));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UserImportMailSystem::format public function Concatenate and wrap the e-mail body. Overrides MailSystemInterface::format
UserImportMailSystem::mail public function Send an e-mail message, using Drupal variables and default settings. Overrides MailSystemInterface::mail