[drupal-support] Sending HTML/Plain text e-mails from within drupal

Stefan Nagtegaal Drupal-Support at Frontaal-Online.com
Thu Mar 3 09:26:35 UTC 2005


Gerhard Killesreiter schreef:

>On Wed, 2 Mar 2005, Stefan Nagtegaal wrote:
>
>  
>
>>My question is quite simple, only the answer gives me nightmares... :-(
>>
>>Is it possible to override the "User e-mail settings" - which are
>>located at '?q=admin/user/configure' - so we can sent html/plain text
>>e-mails with drupal?
>>No matter if this could be done using a module, or whatever.. Any
>>suggestions are welcome, but hacking the core code is the least option
>>in my opinion..
>>
>>Maybe, we want to see this in drupal as a feature?
>>
>>
>>i am using the latest Drupal HEAD.
>>
>>(Gerhard, I know you think they are evil, and they are.. But, the client
>>is King..)
>>    
>>
>
>Well, it is not my client. ;)
>
>What you could do is to abuse Drupal's ability to use an smtp library
>instead of using php mail() directly. Have a look at user_mail to see what
>I mean. Your smtp.inc file could do anything to that mail even adding
>html.
>
>Cheers,
>	Gerhard
>  
>
Okay, I located the smtp.inc file in the Drupal Tips & Tricks directory 
[1]..  But does *every* server allow this kind of e-mailing? I'm not 
sure, but when i did search through my phpinfo(); i found:

PHP Core Configuration:
---------------------------------------------------
| Directive | Local Value | Master Value |
---------------------------------------------------
|   SMTP   |   localhost    |     localhost     |
---------------------------------------------------

And these were the only instances of 'smtp' I could found.


 From smtp.inc:
<snippet>
// The recipients (can be multiple)
  $send_params['recipients'] = $mail;
  // The headers of the mail
  $send_params['headers'] = explode("\n", $header ."\nSubject: 
$subject\nTo: $mail");
  // The body of the email
  $send_params['body'] = str_replace("\n", "\r\n", $message);
</snippet>

I probably have to change the '  $send_params['body'] = 
str_replace("\n", "\r\n", $message);' So it does something like:
<code>
$send_params['body'] = $html_email_begin . str_replace("\n", "\r\n", 
$message) . $html_email_end;
</code>


Gerhard, Thanks for your help! You really got me going...



Stefan.


[1] - http://cvs.drupal.org/viewcvs/drupal/contributions/tricks/smtp/



More information about the drupal-support mailing list