xoops forums

Faustinah

Friend of XOOPS
Posted on: 2008/11/19 23:15
Faustinah
Faustinah (Show more)
Friend of XOOPS
Posts: 41
Since: 2007/5/8 5
#1

Using HTML in Mail Users under System?

Can we use html code in the "body" when we mail all users? Mail users is in the system section on xoops. I tried it and it doesn't work, but maybe I am missing something. Thanks.

ghia

Community Support Member
Posted on: 2008/11/20 2:21
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#2

Re: Using HTML in Mail Users under System?

AFAIK it is only text and some listed tags. I think I have seen somewhere on this forum a patch to change the email message attribute from text to html.

tzvook

Just can't stay away
Posted on: 2009/3/26 13:18
tzvook
tzvook (Show more)
Just can't stay away
Posts: 854
Since: 2003/2/1 2
#3

Re: Using HTML in Mail Users under System?

Since this one : https://xoops.org/modules/newbb/viewto ... id=289857#forumpost289857 is not working for me with 2.3.3 , I'll locate a 3 years old hack and try to make it work with the current version ....

This one should have long ago enter the core .... any email client support HTML , Sending your users text is ridiculous ...

All my 2.2.4 sites has this hack (slightly moded version), I'll be back with the solution - I hope

==================== edit ===============
Found it - send email with html to site members

I'll try and see if it works with 2.3.3 .... later today

Mamba

Moderator
Posted on: 2009/3/26 14:37
Mamba
Mamba (Show more)
Moderator
Posts: 10582
Since: 2004/4/23
#4

Re: Using HTML in Mail Users under System?

Quote:
This one should have long ago enter the core

If it works, can you add it to "Feature Request"?

Thanks...
Support XOOPS => DONATE
Use 2.5.9 | Docs | Modules | Bugs

tzvook

Just can't stay away
Posted on: 2009/3/26 16:01
tzvook
tzvook (Show more)
Just can't stay away
Posts: 854
Since: 2003/2/1 2
#5

Re: Using HTML in Mail Users under System?

Quote:

Mamba wrote:
Quote:
This one should have long ago enter the core

If it works, can you add it to "Feature Request"?

Thanks...


As you can read here
I asked this 3 years ago - and indeed - as I said b4 - all mail clients support HTML - it's a shame XOOPS is still so many years back with mailing users, this feature is just the "tip of the iceberg", but it's a start .

Anyway - I got home and am going to get it to work with 2.3.3 !!!

tzvook

Just can't stay away
Posted on: 2009/3/26 17:10
tzvook
tzvook (Show more)
Just can't stay away
Posts: 854
Since: 2003/2/1 2
#6

Re: Using HTML in Mail Users under System?

OK folks - tested with 2.3.3 and is working fine

(I may add system-wide wysiwyg editor capability later on, but for now it works with TinyEditor/Inbetween which is my favorite by far)

I Took an old hack by sceilig with a few fixes and line corrections by me, and adopted it to XOOPS 2.3.3 with a few small changes (quoting a lot from the original thread) :

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.

This is a quick hack to allow XOOPS 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

// TZ added for HTML mailing //
     // private
     
var $contentType;
            
// END TZ Addition  //


2. in the same file around line 233 (just above setSubject())

// TZ added for HTML mailing //
    // public
    
function setContentType($value)
    {
    if (
$value$this->contentType trim($value);
    }
            
// END TZ Addition  //


3. in the same file around line 420 (just after ($this->encoding)

// TZ added for HTML mailing //
        
$this->multimailer->ContentType $this->contentType;
            
// END TZ Addition  //


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/admin/mailusers/mailusers.php

At line 147 ( $xoopsMailer =& xoops_getMailer(); )
add this lines:

// TZ added for HTML mailing //
            
$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']));
            
// END TZ Addition  //


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:


<html>
<body>
<div style="margin-left: 20px; margin-right:20px;">
{X_MESSAGE}
<br />
<br />
-------------------------------------<br />
Please do not reply to this message.<br />
-------------------------------------<br/ >
<br />
{X_SITENAME}<br />
<A href='{X_SITEURL}'>{X_SITEURL}</a><br />
</div>
</body>
</html>

=================================================================

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

// TZ added for HTML mailing //
include_once(XOOPS_ROOT_PATH "/class/xoopseditor/inbetween/forminbetweentextarea.php");
$body_text = (new XoopsFormInbetweenTextArea(array('caption'=> $body_caption'name'=>'mail_body''value'=>$mail_body'width'=>'100%''height'=>'250px'),true));
            
// END TZ Addition  //


for tinyeditor turn it into:
// $body_text = new XoopsFormTextArea($body_caption, "mail_body", "", 10);

            // TZ added for HTML mailing //
include_once(XOOPS_ROOT_PATH "/class/xoopseditor/tinyeditor/formtinyeditortextarea.php");
$body_text = (new XoopsFormtinyeditorTextArea(array('caption'=> $body_caption'name'=>'mail_body''value'=>$mail_body'width'=>'100%''height'=>'250px'),true));
            
// END TZ Addition  //


NOW - a call to devs - I "cleaned the dust" after 3 years from the original thread, please !!! add it to the core !!!

I can't see my sites without this hack and am tired to apply it to each version that comes out - it a must have one and ... well enough said ...

as said b4 - If not intended to the core - I plan to add system-wide editors to this ...

For small to medium sites - this hack is upgrading the mail-users features quite nicely instead of a mailinglist.

tzvook

Just can't stay away
Posted on: 2009/3/26 18:36
tzvook
tzvook (Show more)
Just can't stay away
Posts: 854
Since: 2003/2/1 2
#7

Re: Using HTML in Mail Users under System?

Just a quick note !!!
If you use the PM option in the mail-users admin, you'll find out that you PM module is non-HTML enable.

There is a fix for that too, but, well, I simply recommend using "mpmanager" module instead of the (XXXXXX) pm module ... which solves the issue.

tzvook

Just can't stay away
Posted on: 2009/3/28 12:09
tzvook
tzvook (Show more)
Just can't stay away
Posts: 854
Since: 2003/2/1 2
#8

Using WYSIWYG in Mail-Users

BUMP !!!!

This time this one got to get into the core .... such a simple ... yet .... so needed addition ....

Yes - I know - there's a solution for turning all textarea into wysiwyg - that's the worst solution there is ....

sailjapan

Moderator
Posted on: 2009/3/30 0:11
sailjapan
sailjapan (Show more)
Moderator
Posts: 1672
Since: 2005/11/16
#9

Re: Using WYSIWYG in Mail-Users

Feature request added.

Very useful hack, tvzook. Thank you!
Never let a man who does not believe something can be done, talk to a man that is doing it.

tzvook

Just can't stay away
Posted on: 2009/3/30 13:31
tzvook
tzvook (Show more)
Just can't stay away
Posts: 854
Since: 2003/2/1 2
#10

Re: Using WYSIWYG in Mail-Users

One more thing:

Since Wysiwyg is used to send mail, all links MUST BE absolute !!! orelse will lead to something like .../.../uploads/whatever ......
same regarding to embed photos ...

So - if you use TinyEditor - there's an old bug regarding the Absolute/relevant path ... the preferences at the admin is not working right.
My solution was to force absolute path all the time (I like it site-wide anyway from SEO point of view)

If you need it too - open /modules/tinyeditor/include/initcode.php
look for line 257

replace
if ($moduleConfig['tinyedrelurls'] == '0') {
            echo 
'relative_urls : "false",';
        } else {
            echo 
'relative_urls : "true",';
            echo 
'remove_script_host : "true",';
        }


With:
if ($moduleConfig['tinyedrelurls'] == '1') {
            echo 
'relative_urls : "false",';
        } else {
            echo 
'relative_urls : "false",';
            echo 
'remove_script_host : "false",';
        }

//            TZ commernted out and replaced with the above code
//        if ($moduleConfig['tinyedrelurls'] == '0') {
//            echo 'relative_urls : "false",';
//        } else {//            echo 'relative_urls : "true",';
//            echo 'remove_script_host : "true",';
//        }


That will do it ...

Now that FrankBlack is around again - hope he'll send some bug fixes to that great-great module ...