Modifying email templates

alt=
DannyA
@dannya
10 years ago
584 posts
Where do you modify email templates for notifications?
updated by @dannya: 02/05/15 12:04:50PM
SteveX
SteveX
@ultrajam
10 years ago
2,584 posts
They should be in the module templates directory:
email_yourfunction_message.tpl
email_yourfunction_subject.tpl

Or overridden in the skin directory:
yourModule_email_yourfunction_message.tpl
yourModule_email_yourfunction_subject.tpl


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
alt=
DannyA
@dannya
10 years ago
584 posts
Is it possible to send HTML emails? I want to add a standard header and footer that goes on all emails
brian
@brian
10 years ago
10,148 posts
DannyA:
Is it possible to send HTML emails? I want to add a standard header and footer that goes on all emails

Yeah - you just need to make sure in your jrCore_send_email() function call you add a special "send_as_html" flag - i.e.

jrCore_send_email($email, $sub, $msg, array('send_as_html' => true));

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
DannyA
@dannya
9 years ago
584 posts
I have the the flag to send_as_html. Still having 2 problems

1. sending a test email from the the Communication--> email support--> tools--> test email
The HTML does not get parsed. Is that by design? Is it just for testing delivery settings?

2. Is there a "Master" template I can modify that will modify the header/footer/syle of ALL email templates?

3. URL's not being displayed as links

e.g. in new follower notification :

{$follower_name} is now following you:

{$follower_profile_url}

is displayed as

-------------------------------------------------------------------------------
admin is now following you:

http://email.MYDOMAIN.com/c/ZD1mNThkMiZpPTIwMTUwMTA1MDgwOTMwLjg3NjMuNTAyNzMlNDBjbGVhcnRyYWNrcy5jb20maD1mMjNiNjM2NzE0MWM1YWUyYjE4MTM5OWI2YTUwNDVhNiZsPWh0dHBzJTNBJTJGJTJGZGV2LmNsZWFydHJhY2tzLmNvbSUyRmFkbWluJnI9bGFiZWw1JTQwZGV2LmNsZWFydHJhY2tzLmNvbQ
-------------------------------------------------------------------------
I just want it to show up as:

Admin is now following you. (admin being a link)
updated by @dannya: 01/05/15 12:25:32AM
brian
@brian
9 years ago
10,148 posts
1) Yes - the "test email" function just sends a plain text email (it is designed to test delivery)

2) yes - the jrUser/templates/email_preferences_footer.tpl is applied to all emails. There is no overall header template.

3) You have to write them as HTML and send as HTML for that to work (i.e. you want text to be clickable that points to a URL).


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
DannyA
@dannya
9 years ago
584 posts
So for #3, I can just insert any JRFunction and it will insert it into the HTML. (I'm sure this was obvious but I had no idea the email templates worked that way). So what i want is:
<a href={$follower_profile_url} {$follower_name} </a> is following you.
Correct?

I'm surprised all the email templates aren't HTML (with failover to text) by default. Isn't html the default format of email for the past 20 years or so? Am I doing something wrong here?
brian
@brian
9 years ago
10,148 posts
DannyA:
So for #3, I can just insert any JRFunction and it will insert it into the HTML. (I'm sure this was obvious but I had no idea the email templates worked that way). So what i want is:
<a href={$follower_profile_url} {$follower_name} </a> is following you.
Correct?

Sort of - the variables available inside are going to change a bit depending on the email template, but yeah - that's correct.

Quote:
I'm surprised all the email templates aren't HTML (with failover to text) by default. Isn't html the default format of email for the past 20 years or so? Am I doing something wrong here?

I don't believe so at all - "transactional" emails (i.e. validation, forgot email, short notifications, etc.) in my opinion should be text, but other types of email (say a newsletter, etc.) can be HTML/text. That is sort of the industry "standard" for SAAS, which is why we've set it up that way.

One thing we can add that might help though is to set it up so if HTML is detected in the message it sends it as HTML, otherwise text - that keeps you from having to worry about the send_as_html flag. I thought about that when looking at for my first response, so will try to get that in.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 01/05/15 01:18:20PM
alt=
DannyA
@dannya
9 years ago
584 posts
Quote:
One thing we can add that might help though is to set it up so if HTML is detected in the message it sends it as HTML, otherwise text - that keeps you from having to worry about the send_as_html flag. I thought about that when looking at for my first response, so will try to get that in.
I think that's the core of my issue. When i was sending the default emails, and Mailchimp re-writes the links with their own (extremely long)unique url, the notification looks like a mess. One of the things I'm trying to do is simply hide the url of the link.

Beyond that, it would be nice to be able to include some basic Header (logo), footer (links and disclaimers), and some basic inline css (style, theme(skin) colors). It seems like html/txt would be the better option.
brian
@brian
9 years ago
10,148 posts
You can do that - the email templates are smarty templates, so you can make yourself a custom email_header.tpl file and use jrCore_include to include it - i.e.

{jrCore_include module="CustomModule" template="email_header.tpl"}


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 01/05/15 02:14:11PM

Tags