Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

[New] Email Templates

Information about updates, news, Code Library
admin
Site Admin
Posts: 2778
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5

[New] Email Templates

Unread post by admin »

Email Templates allow you to create saved templates that can be easily retrieved and sent out by email.

Features:
  • Add fields from a form
  • Apply formatting (bold, italic, underline)
  • Preview
Email template manager:
email template.png
email template.png (30.08 KiB) Viewed 365 times


:arrow: Example PHP code in AS (After Save) event to send an email using a template:

Code: Select all

// Retrieve the template data
$template = nuGetEmailTemplateData("example_template");
if ($template == false) {
    nuDisplayError('Unknown email template!');
    return;
}

$sendResult = sendEmailFromTemplate($template);
if ($sendResult[0] != true) {
    nuDisplayError($sendResult[1].'<br>'.$sendResult[2]);
}

// Sends an email message using an email template.
function sendEmailFromTemplate($template) {

    $params = array(
        'to' => $template['to'],
        'cc' => $template['cc'],
        'bcc' => $template['bcc'],
        'body' => nl2br($template['body']),
        'subject' => $template['subject']
    );
   
    // Replace all Hash Cookies
    foreach ($params as $key => $value) {
        $params[$key] = nuReplaceHashVariables($value);
    }

    return nuSendEmail($params);

}
Post Reply