<div dir="ltr"><span>I'm personally a fan of using the smtp_library configuration option to hijack the mail sending process. I normally use something along the lines of the following...<br><br>file: db_smtp.inc<br>==================================<br>
/**<br>* Log the mails in db instead of mailing.<br>*/<br>function drupal_mail_wrapper($mailkey, $to, $subject, $body, $from, $headers) {<br> $mimeheaders = array();<br> foreach ($headers as $name => $value) {<br> // the check_plain nicely encodes <> chars for web presentation<br>
$mimeheaders[] = check_plain($name .': '. mime_header_encode($value));<br> }<br> db_query("INSERT INTO {db_smtp_mail} <br> (mailkey, mail_to, mail_from, subject, body, headers) <br> VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", <br>
$mailkey, $to, $subject, $body, $from, implode("\n ", $mimeheaders));<br> return mysql_insert_id();<br>}<br><br>In my simple tests I just grab global $conf; and set $conf['smtp_library'] = 'path/to/db_smtp.inc'. This breaks if drupal_mail_wrapper is defined else where. I really wish it were strip_extension($conf['smtp_library']) .'_mail_wrapper() that was invoked instead of drupal_mail_wrapper, or $conf['smtp_library'] referenced a module with the default being drupal.<br>
</span><br></div>