The XoopsMailer class builds upon the powerful phpmailer email class - this can be used to send emails as text, html or with multipart attachments.
The default setting for content-type in that class is "text/plain" which is why all XOOPS mails go out as text.
I did a quick hack to allow me to control the content-type setting per instance of using the XoopsMailer. So say for most emails being sent out (like forgot password, change email etc) they could appear as text, but if I wanted to have the "Mail Users" admin function send emails as html, I did the following hacks.
1. edit class/xoopsmailer.php and at line 96 (just above var $subject) add a contentType variable
Quote:
// private
var $contentType;
2. in the same file around line 209 (just above setSubject())
Quote:
// public
function setContentType($value)
{
if ($value) $this->contentType = trim($value);
}
3. in the same file around line 399 (just after ($this->encoding)
Quote:
$this->multimailer->ContentType = $this->contentType;
4. Now depending on what module you are using for sending emails to users, you add a couple of fields to your $xoopsMailer instance.
e.g. for sending html emails using the main "Mail Users" administration function, edit this file:
modules/system/mailusers/mailusers.php
At line 157 (just after $xoopsMailer =& getMailer();)
add this lines:
Quote:
$xoopsMailer->setContentType("text/html");
$xoopsMailer->setTemplate('mailusers.tpl');
$xoopsMailer->assign('X_SITENAME', $xoopsConfig['sitename']);
$xoopsMailer->assign('X_SITEURL', XOOPS_URL."/");
$xoopsMailer->assign('X_MESSAGE', $myts->oopsStripSlashesGPC($_POST['mail_body']));
What Im doing here is setting the ContentType to be text/html. Then using a mail template I created called 'mailusers.tpl'. This template (stored in language/english/mail_template/) is essentially a html file containing my website header and footer, as well as XOOPS placeholders for the content of the email (X_MESSAGE) and Name of the website.
This would be a simple example of that template:
Quote:
{X_MESSAGE}
-------------------------------------
Please do not reply to this message.
-------------------------------------
{X_SITENAME}
{X_SITEURL}
5. Implement a html editor for creating the body of the email like inbetween or fckeditor. For the "Mail Users" function, you would edit modules/system/admin/mailusers/mailform.php
then uncomment line 82 ($body_text = new XoopsFormTextArea ......)
and put this call to the Inbetween editor instead
Quote:
include_once XOOPS_ROOT_PATH . "/class/xoopseditor/inbetween/forminbetweentextarea.php";
$body_text = new XoopsFormInbetweenTextArea(array('caption'=> $body_caption, 'name'=>'description', 'value'=>$mail_body, 'width'=>'100%', 'height'=>'250px'),true));
I realise some other people on the forums are working on coming up with a full newsletter module but I needed a solution now rather than later for a website I was creating. I cant guarantee that the above code will cause problems somewhere along the line or if there is even a better approach. Most likely certain people using plain text email clients might have problems viewing emails, and also AOL users (html links need to be done a different way). If looking for a more solid approach you would have to hack the xoopsmailer further, and implement some other phpmailer calls
http://phpmailer.sourceforge.net/It also wouldnt be that difficult to implement the above hack for the evennews module.