/**
  * 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'] = MailFormatHelper::wrapMail($message['body']);
     return $message;
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function format(array $message)
 {
     // Join the body array into one string.
     $message['body'] = implode("\n\n", $message['body']);
     // Convert any HTML to plain-text.
     $message['body'] = MailFormatHelper::htmlToText($message['body']);
     // Wrap the mail body for sending.
     $message['body'] = MailFormatHelper::wrapMail($message['body']);
     return $message;
 }
 /**
  * Concatenate and wrap the e-mail body for either
  * plain-text or HTML emails.
  *
  * @param $message
  *   A message array, as described in hook_mail_alter().
  *
  * @return
  *   The formatted $message.
  */
 public function format(array $message)
 {
     $this->AllowHtml = $this->smtpConfig->get('smtp_allowhtml');
     // Join the body array into one string.
     $message['body'] = implode("\n\n", $message['body']);
     if ($this->AllowHtml == 0) {
         // Convert any HTML to plain-text.
         $message['body'] = MailFormatHelper::htmlToText($message['body']);
         // Wrap the mail body for sending.
         $message['body'] = MailFormatHelper::wrapMail($message['body']);
     }
     return $message;
 }
 /**
  * Makes sure that drupal_wrap_mail() wraps the correct types of lines.
  */
 public function testWrapMail()
 {
     $delimiter = "End of header\n";
     $long_file_name = $this->randomMachineName(64) . '.docx';
     $headers_in_body = 'Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document; name="' . $long_file_name . "\"\n";
     $headers_in_body .= "Content-Transfer-Encoding: base64\n";
     $headers_in_body .= 'Content-Disposition: attachment; filename="' . $long_file_name . "\"\n";
     $headers_in_body .= 'Content-Description: ' . $this->randomMachineName(64);
     $body = $this->randomMachineName(76) . ' ' . $this->randomMachineName(6);
     $wrapped_text = MailFormatHelper::wrapMail($headers_in_body . $delimiter . $body);
     list($processed_headers, $processed_body) = explode($delimiter, $wrapped_text);
     // Check that the body headers were not wrapped even though some exceeded
     // 77 characters.
     $this->assertEquals($headers_in_body, $processed_headers, 'Headers in the body are not wrapped.');
     // Check that the body text is wrapped.
     $this->assertEquals(wordwrap($body, 77, " \n"), $processed_body, 'Body text is wrapped.');
 }
示例#5
0
 /**
  * Tests that trailing whitespace from Usenet style signatures is not removed.
  *
  * RFC 3676 says, "This is a special case; an (optionally quoted or quoted and
  * stuffed) line consisting of DASH DASH SP is neither fixed nor flowed."
  *
  * @see \Drupal\Core\Mail\MailFormatHelper::wrapMail()
  */
 public function testUsenetSignature()
 {
     $text = "Hi there!\n-- \nHerp Derp";
     $mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
     $this->assertEqual("-- ", $mail_lines[1], 'Trailing whitespace not removed for dash-dash-space signatures.');
     $text = "Hi there!\n--  \nHerp Derp";
     $mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
     $this->assertEqual("--", $mail_lines[1], 'Trailing whitespace removed for incorrect dash-dash-space signatures.');
 }