Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: tjbalon on December 30, 2015, 02:06:17 AM

Title: SMF 2.0.11 -- HTML Emails
Post by: tjbalon on December 30, 2015, 02:06:17 AM
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.
Title: Re: SMF 2.0.11 -- HTML Emails
Post by: tjbalon on December 30, 2015, 03:27:12 AM
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 (http://custom.simplemachines.org/mods/index.php?mod=2926)). 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)
Title: Re: SMF 2.0.11 -- HTML Emails
Post by: PyroTech03 on December 24, 2016, 04:43:03 PM
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?