• Welcome to Simple Machines Community Forum. Please login or sign up.
December 01, 2021, 05:53:21 PM


Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

SMF 2.0.11 -- HTML Emails

Started by tjbalon, December 30, 2015, 02:06:17 AM

Previous topic - Next topic


December 30, 2015, 02:06:17 AM Last Edit: December 30, 2015, 02:46:51 AM by balonfx
I am looking to convert all of my forums to using HTML emails, it helps quite a bit with a more informational footer included, and this is hard to achieve via text.

So far I've found a few threads on this forum giving a general concept on how to change around individual emails to send as HTML. I'd like to find a way to do it all in one shot.

In Sources/Subs-Post.php..
bool sendmail(array to, string subject, string message,
string message_id = auto, string from = webmaster,
bool send_html = false, int priority = 3, bool hotmail_fix = null)
- sends an email to the specified recipient.
- uses the mail_type setting and the webmaster_email global.
- to is he email(s), string or array, to send to.
- subject and message are those of the email - expected to have
  slashes but not be parsed.
- subject is expected to have entities, message is not.
- from is a string which masks the address for use with replies.
- if message_id is specified, uses that as the local-part of the
  Message-ID header.
- send_html indicates whether or not the message is HTML vs. plain
  text, and does not add any HTML.
- returns whether or not the email was sent properly.

Would editing this function..
function sendmail($to, $subject, $message, $from = null, $message_id = null, $send_html = false, $priority = 3, $hotmail_fix = null, $is_private = false)

My thought is in this function, change $send_html to true.

so $send_html = true; in the function.

Possibly change ALL emails to HTML? Or where can I change the default value in this bool, to take out send_html = false to always true. (I have no problem rewriting all the email templates, with proper spacing and URLs.

I've taken backups, and all the standard precautions. Currently, I'm only doing this on a development site, not live production. (I'll know there will be some people who strongly encourage I don't do this in live, etc).

Many Thanks.
If this is the wrong section, my apologies.


December 30, 2015, 03:27:12 AM #1 Last Edit: December 30, 2015, 04:02:58 AM by balonfx
Ok, so because someone is eventually going to look up how to do this one day, I'll include what I've done here, as it's working....

Make sure you back up your Sources and Themes/default/languages before starting, because you can easily mess a few things up (I know I did. Gladly we take hourly backups of everything via rysnc).

In Sources/Subs-Post.php..
On about line 623 (Under the function sendmail)
Add the line:
$send_html = true;

This will override anything in SMF sending the parameter false in HTML, allowing all emails to now go as HTML. (From what I've observed!).

This comes with quite a bit of work. You will now need to edit all emails sent from your website to handle HTML.

You can do so either via /Themes/default/languages -- Using EmailTemplates.english.php and add spacing and a href's respectively, or do such with a template editor... (click here). You will need to emulate to SMF 2.0 RC5.

You'll also need to edit any pre-existing modifications you've installed which send emails.

If you go with the mod, one neat feature is that you can send test-emails to see how your users will see your new HTML-Emails.

Lastly -- you can now make html based email "footers", such as adding your logo, changing how you sign off, and much more.

Happy updates.
(Again, not sure if this is the proper section)


I know this post is almost a year old, but is there anywhere to download the template editor?

Or how do I edit the bodies to properly show? Do I just do html open/close tags on it like a regular page?
YouTube personality PyroTech03 http://www.youtube.com/pyrotech03stream [nofollow]

Owner of Obtenebration Network, home for YouTube gaming content creators and fans! http://www.obten.net [nofollow]