drupal_mail() is formatting my email body. Before: http://pastebin.com/LbBy04BZ (note 1 line) After: http://pastebin.com/nEx7AFwU (note multiple lines)

It should not, because Line 23 in /modules/system/system.mail.inc is the following one:

$message['body'] = implode("\n\n", $message['body']);

How can I prevent the reformatting of my mail content?

1 Answer 1


Have a look at the API documentation for drupal_mail_system(), there you'll have code to override the default MailSystemInterface.

For an exemple of how to override it, have a look at the Postmark module.
You can then redefine the format() function:

class YourModuleMailSystem implements MailSystemInterface {

public function format(array $message) {
  //remove this formatting.
  //$message['body'] = implode("\n\n", $message['body']);
  return $message;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.