Hi all,

I'm using the messaging & notifications modules, and have redirected the Drupal 
system emails with drupal_mail_wrapper() to travel through the 
messaging_phpmailer framework.
This enables the client's "lost password" emails to travel via gmail, for 
example, which is the the same account their notifications are sent.

Anyway, I have this working except for line breaks. The final "lost password" 
email arrives as a single line, with no breaks.

I've added a debugging routine that appends a string to a file, and with that 
writing out the email body as it travels into the messaging_phpmailer logic I 
can see line breaks starting as "\r", get converted to "\n" before being sent, 
and lost somewhere during the send process. However, emails sent through the 
same logic by the messaging module have line breaks and complete rich text just 
fine.

It looks like the only place the change could occur is inside 
hook_mail_alter(), but a grep of my contributed modules is not showing any 
implementations of "_mail_alter"...

Anyone have any experience / advice? 

The necessary logic to do this is quite simple, once the messaging framework 
has been setup:

// the only thing inside cex_mail.module:
function cex_mail_enable() {
        variable_set('smtp_library', drupal_get_path('module','cex_mail') . 
'/smtp.inc.php');
}

// contents of smtp.inc.php:
function drupal_mail_wrapper($message) {
        
        // simply appends string to a file:
        _cexReport( 'drupal_mail_wrapper: got "'.print_r( $message, 1 ).'"' );

        // tried all kinds of variations here, nothing seems to make a 
difference:
        $message['body'] = str_replace( "\r", '', $message['body'] );

        return messaging_phpmailer_send_msg( $message['to'], (object)$message, 
$message['params'] );
}

With the exception of the line break issue, this works fine. 

Sincerely,
-Blake
[email protected]
www.BlakeSenftner.com
www.MissingUbercartManual.com

Reply via email to