Loading...
 
Features / Usability

Features / Usability


HTML in email

posts: 3

Hey,
is there any way for tiki to send HTML emails? I'm talking about email address validation emails to be specific. I want them to be more modern than just a plain text. I've tried adding the HTML code to the template .tpl file but it sends it as plaintext and doesn't parse it for HTML code.

Please help.

posts: 159
Szymon wrote:

Hey,
is there any way for tiki to send HTML emails? I'm talking about email address validation emails to be specific. I want them to be more modern than just a plain text. I've tried adding the HTML code to the template .tpl file but it sends it as plaintext and doesn't parse it for HTML code.

Please help.


You have to send the appropriate MIME header for this, otherwise the receiving mail client will interpret !!everything!! as plain text.

codeMIME-Version: 1.0
text/html; charset=utf-8/code

is what you need, and don't forget to define and use boundaries...

However, be careful not so send HTML only without an additional plaintext fallback, because it is standard security advice to disable or filter HTML on mail clients, as it is potentially dangeous - because you can manipulate links with HTML.

A HTML only mail could be presented to the user as "empty", most of the times this happens in security aware companies. And if the user is in a company with good IT administration, the user cannot change this behaviour on his/her own....

Hman

posts: 3
hman wrote:

You have to send the appropriate MIME header for this, otherwise the receiving mail client will interpret !!everything!! as plain text.

codeMIME-Version: 1.0
text/html; charset=utf-8/code

is what you need, and don't forget to define and use boundaries...

How do I add those headers? I've tried to add them in the .tpl file that stores the mail's content but It was still sent as a plain text

posts: 159
Szymon wrote:
How do I add those headers? I've tried to add them in the .tpl file that stores the mail's content but It was still sent as a plain text


I guess if Tiki Wiki doesn't use headers, there is nothing you can do except for patching it's call for mail. The PHP call for mailing that is aptly named mail:

https://www.php.net/manual/en/function.mail.php

You could grep the source code to find out where Tiki Wiki calls mail and patch it, passing the new parameter $additional_headers that you have to define. Remember to make a copy of your patched code someplace else, so it won't get overwritten if one day you upgrade your Tiki Wiki. When upgrading, you will have to manually port your patch to the next version, which shouldn't be too hard.

While reading this PHP manual page, it mentions that headers can alternatively be defined in php.ini, you could try to patch that as well.

Also, keep a copy of the original Tiki Wiki files and the php.ini to be able the go back to it, just in case :-)


posts: 3

Managed to get it to work!
For other looking for solution, I've discovered that tiki-login_validate.tpl uses TikiMail() class to generate emails. From there you can check the tikimaillib.php and see, that the class has a setHtml() function. Simply use the setHtml() function istead of the default setText() function on your emails.


Upcoming Events

No records to display

Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.