Send Message function - Email Templates
4 posts by 3 authors in: Forums > CMS Builder
Last Post: February 21, 2013 (RSS)
Hello,
With the new releases of cmsBuilder I have been creating custom Email Templates, which are stored in the table "_email_templates".
I was wondering what function I should be using to send the Email Template messages. Can someone please advise?
I'd like to use one of the existing functions to send email templates so I don't need to modify any of the core files.
Currently we are using a custom written function, which I would like to get rid of.
Thank you for your help.
Regards,
Greg
Hi Greg,
Here is some example code:
$emailHeaders = emailTemplate_loadFromDB(array(
'template_id' => 'PUBLISH-REQUEST-USER',
'placeholders' => array(
'name' => 'Greg',
'cause' => $causeInfo['title'],
'url' => 'http://www.google.com',
'email' => $CURRENT_USER['email'],
)));
$errorsAndAlerts = sendMessage($emailHeaders);
The template_id variable is the template that you want to use. The placeholders is an array of items that can be passed into the template and displayed.
For example if I wanted to display the name of a user in the template I would add #name# into the content WYSIWYG editor for a template. Then when the e-mail was sent the #name# would be replaced with Greg.
You can also override items you have set in the template using the following variables:
$emailHeaders = emailTemplate_loadFromDB(array(
'template_id' => 'USER-ACTION-NOTIFICATION',
'placeholders' => $placeholders,
'override-from' => 'test@example.com' //override who the e-mail appears from.
'override-to' => 'test2@example.com' //override who the e-mail goes to.
'override-subject'' => 'This is a test' //override the subject line.
'override-html' => '<html><body><h1>TEST</h1></body></html>' //override the content of the e-mail.
));
Let me know if you have any questions.
Thanks!
Greg
PHP Programmer - interactivetools.com
By Dave - February 21, 2013
And we're going to be adding a code generator for this in 2.52 beta (not yet released). Changelog:
- Programmers: Added "Export showMessage() PHP" option to Email Templates menu under Advanced Commands
interactivetools.com
Hi guys,
Thanks for your responses. I will get back to you if I have any more questions. The Code Generator will be a big help so I look forward to seeing that!
Kind regards,
Greg