Skip to content

Instantly share code, notes, and snippets.

@webbj74
Created October 10, 2013 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webbj74/6911428 to your computer and use it in GitHub Desktop.
Save webbj74/6911428 to your computer and use it in GitHub Desktop.
Devel 6.x-1.27's mail wrapper
// Devel 6.x-1.27's mail wrapper
// $conf['smtp_library'] is set to path/to/devel.module
// Only define our mail wrapper if the devel module is the current mail
// wrapper.
if (variable_get('smtp_library', '') == drupal_get_filename('module', 'devel')) {
/**
* Log the mails sent out instead of mailing.
*/
function drupal_mail_wrapper($message) {
$mimeheaders = array();
foreach ($message['headers'] as $name => $value) {
// the check_plain nicely encodes <> chars for web presentation
$mimeheaders[] = check_plain($name .': '. mime_header_encode($value));
}
watchdog(
'devel',
'Mail sent:<br />Id: %mail_id<br />To: %to<br />From: %from<br />Language: %lang<br />Subject: %subject<br />Body: %body<br /><br />Additional headers: <br />!header',
array(
'%mail_id' => $message['id'],
'%to' => $message['to'],
'%from' => $message['from'],
'%lang' => $message['language']->language,
'%subject' => $message['subject'],
'%body' => $message['body'],
'!header' => implode("<br />", $mimeheaders),
WATCHDOG_INFO,
)
);
return TRUE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment