You are here

class SimplenewsHTMLTestingMailSystem in Simplenews 7

Same name and namespace in other branches
  1. 7.2 includes/simplenews.mail.inc \SimplenewsHTMLTestingMailSystem

A mail sending implementation that captures sent messages to a variable.

This class is for running tests or for development and does not convert HTML to plaintext.

Hierarchy

Expanded class hierarchy of SimplenewsHTMLTestingMailSystem

1 string reference to 'SimplenewsHTMLTestingMailSystem'
SimplenewsSourceTestCase::testSendHTML in tests/simplenews.test
Send a newsletter with the HTML format.

File

includes/simplenews.mail.inc, line 902
Simplenews email send and spool handling

View source
class SimplenewsHTMLTestingMailSystem implements MailSystemInterface {

  /**
   * Implements MailSystemInterface::format().
   */
  public function format(array $message) {

    // Join the body array into one string.
    $message['body'] = implode("\n\n", $message['body']);

    // Wrap the mail body for sending.
    $message['body'] = drupal_wrap_mail($message['body']);
    return $message;
  }

  /**
   * Implements MailSystemInterface::mail().
   */
  public function mail(array $message) {
    $captured_emails = variable_get('drupal_test_email_collector', array());
    $captured_emails[] = $message;

    // @todo: This is rather slow when sending 100 and more mails during tests.
    // Investigate in other methods like APC shared memory.
    variable_set('drupal_test_email_collector', $captured_emails);
    return TRUE;
  }

}

Members