Example #1
1
 /**
  * Concatenate and wrap the e-mail body for plain-text mails.
  *
  * @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']);
     $message['body'] = drupal_wrap_mail($message['body']);
     return $message;
 }
 /**
  * Concatenates and wraps the email body for plain-text mails.
  *
  * @param array $message
  *   A message array, as described in hook_mail_alter().
  *
  * @return array
  *   The formatted $message.
  */
 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'] = drupal_html_to_text($message['body']);
     // Wrap the mail body for sending.
     $message['body'] = drupal_wrap_mail($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'] = drupal_html_to_text($message['body']);
         // Wrap the mail body for sending.
         $message['body'] = drupal_wrap_mail($message['body']);
     }
     return $message;
 }
 /**
  * Makes sure that drupal_wrap_mail() wraps the correct types of lines.
  */
 function testDrupalWrapMail()
 {
     $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 = drupal_wrap_mail($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->assertEqual($headers_in_body, $processed_headers, 'Headers in the body are not wrapped.');
     // Check that the body text is wrapped.
     $this->assertEqual(wordwrap($body, 77, " \n"), $processed_body, 'Body text is wrapped.');
 }
 /**
  * Tests that drupal_wrap_mail() does not remove the trailing whitespace from
  * Usenet style signatures.
  *
  * 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."
  */
 public function testUsenetSignature()
 {
     $text = "Hi there!\n-- \nHerp Derp";
     $mail_lines = explode("\n", drupal_wrap_mail($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", drupal_wrap_mail($text));
     $this->assertEqual("--", $mail_lines[1], 'Trailing whitespace removed for incorrect dash-dash-space signatures.');
 }