MyBB Community Forums

Full Version: html code in messages.lang.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
While HTML mails are possible in mass mail, it seems a little hard to achieve it in system messages, e.g. defined in messages.lang.php.

According this post
https://community.mybb.com/thread-101068...#pid738502
and for MyBB 1.6, it should be possible by editing the file functions.php
I've tried it and edited line 566 from

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="[b]text[/b]", $message_text="", $return_email="")

to

function my_mail($to, $subject, $message, $from="", $charset="", $headers="", $keep_alive=false, $format="[b]html[/b]", $message_text="", $return_email="")

But it would not render any html. I also tried instead of 'html' the input 'both'.
Does anyone know if it is somehow possible to create system mails in html?

I would find html e-mails really useful as many mail clients on mobile devices do not link URL's unless they are sent in HTML format.
Hi,

you could change the class_mailhandler.php file.

In line 99 change:
public $parse_format = 'text';

for html or both as you want (remember, no caps).

You'll have to change this file everytime MyBB updates it  Wink
Thank you for this suggestion. Just tested it using the internal messaging system to send an e-mail to a forum user.
The email still arrives in plain text. To test it, I added in Config > Languages > mylanguage > messages.lang.php in the respective box (email_sendtofriend) an HTML href link and some other html code.

The link and the other html content does not show up, also not as plain text. It seems to be somewhat more complicated.
Hi again,

do you have this option enabled? 
Quote:Allow HTML

Selecting Yes will allow HTML to be used in private messages.
Admin CP -> Configuration (Tab) -> Settings -> Private Messaging
Maybe this was the problem with the email.
Thanks for that pointer. Just tested, but unfortunately this has only an effect om PM's , not on system mails. After all it's not a complete showstopper. Most mail clients on desktops will show the URL as a link. But many mobile mail apps, show the URL as plaintext. Thats a bit annoying, particularly if you get mail notifications about new replies where links are not clickable.

Keeping the finger on the plaintext link will copy the link so it can be used on a browser app, but it's not that pretty this way.