Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
HTML Formatting and Emails
We've installed the CLEditor extension, and are using HTML Purifier on our site. As a result, nearly every post has at least basic HTML formatting in it. Additionally, we've set all the default notification settings to maximum, so every post results in emails being sent somewhere.
This is all fine, except that the emails are always sent in text format, rather than HTML format. I looked briefly at the code, and it seems that the entire Vanilla email design assumes that all emails will be plaintext, not HTML. Am I right?
Is there any way to configure this (or easily modify it) to allow these emails (especially notifications) to be sent in HTML format, or better yet, to use multipart to send both HTML and plaintext in the same message?
I know some purists might think this is a terrible thing that I'm asking for, but it really isn't. I don't want to send out massive highly stylized advertisement newsletter monoliths. I think the user experience would actually be greatly improved if any WYSIWYG formatting used in the post (including links, bold, italics, paragraphs) were preserved in the email. Right now it is just sending a jumbled glob of meaningless gobbledy gook.
This is all fine, except that the emails are always sent in text format, rather than HTML format. I looked briefly at the code, and it seems that the entire Vanilla email design assumes that all emails will be plaintext, not HTML. Am I right?
Is there any way to configure this (or easily modify it) to allow these emails (especially notifications) to be sent in HTML format, or better yet, to use multipart to send both HTML and plaintext in the same message?
I know some purists might think this is a terrible thing that I'm asking for, but it really isn't. I don't want to send out massive highly stylized advertisement newsletter monoliths. I think the user experience would actually be greatly improved if any WYSIWYG formatting used in the post (including links, bold, italics, paragraphs) were preserved in the email. Right now it is just sending a jumbled glob of meaningless gobbledy gook.
0
Comments
1. Jon Abernathy wrote an awesome bit of code (GPL license) that can build decent plaintext content from an HTML formatted input: http://www.chuggnutt.com/html2text.php (this could be used to process the user body, which, unless I'm mistaken, should have technically already been returned from the formatting functions in HTML format.)
2. On the one hand, emails are pretty language specific, but on the other hand, it doesn't seem clean to have the email templates in the locale, because they are "personal" way beyond just a translation level. Would it be better to put these somewhere more immediately and obviously configurable?
3. The email definitions should (ideally) have both HTML and non-HTML versions, so that the right one can be selected by the system when it is needed without people needing to rewrite the emails. Alternately only HTML versions + html2text would be sufficient, but not perfect.
Have you managed to send both HTML and plaintext in the same message since then?
I've just done it.
It is PHPMailer who sends emails. PHPMailer has a property called 'AltBody'. When it is set PHPMailer knows that you would like to send a multipart message and you want the text/plain portion of the mail to be the value of 'AltBody'. In the current version of Garden there is no way for you to set the property, so unfortunately, you have to modify the core.
Step 1: Add ability to set 'AltBody' by adding the following function to library/core/class.email.php
Step 2: Find all the places in Garden where email is sent by searching for the text '$Email->Message' in Garden files.
Step 3: Set 'AltBody' whenever you want to send a text/plan part beside the text/html part by adding the line
(with your own message) after the existing line with '$Email->Message'.
You may need to use the same logic that '$Email->Message' uses in order to be able to use email templates from the locales which needs to be created then as well.