1
Faustinah
Using HTML in Mail Users under System?
  • 2008/11/19 23:15

  • Faustinah

  • Friend of XOOPS

  • Posts: 41

  • Since: 2007/5/8 5


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.

2
ghia
Re: Using HTML in Mail Users under System?
  • 2008/11/20 2:21

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


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.

3
tzvook
Re: Using HTML in Mail Users under System?
  • 2009/3/26 13:18

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


Since this one : https://xoops.org/modules/newbb/viewtopic.php?post_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

4
Mamba
Re: Using HTML in Mail Users under System?
  • 2009/3/26 14:37

  • Mamba

  • Moderator

  • Posts: 11521

  • Since: 2004/4/23


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.11 | Docs | Modules | Bugs

5
tzvook
Re: Using HTML in Mail Users under System?
  • 2009/3/26 16:01

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


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 !!!

6
tzvook
Re: Using HTML in Mail Users under System?
  • 2009/3/26 17:10

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


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

le="color: #000000"><?php // TZ added for HTML mailing // // private var $contentType; // END TZ Addition //


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

le="color: #000000"><?php // 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)

le="color: #000000"><?php // 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:

le="color: #000000"><?php // 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

le="color: #000000"><?php // 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:
le="color: #000000"><?php // $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.


7
tzvook
Re: Using HTML in Mail Users under System?
  • 2009/3/26 18:36

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


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.

8
tzvook
Using WYSIWYG in Mail-Users
  • 2009/3/28 12:09

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


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 ....

9
sailjapan
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.

10
tzvook
Re: Using WYSIWYG in Mail-Users
  • 2009/3/30 13:31

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


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
le="color: #000000"><?php if ($moduleConfig['tinyedrelurls'] == '0') { echo 'relative_urls : "false",'; } else { echo 'relative_urls : "true",'; echo 'remove_script_host : "true",'; }


With:
le="color: #000000"><?php 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 ...

Who's Online

164 user(s) are online (134 user(s) are browsing Support Forums)


Members: 0


Guests: 164


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits