Email Templates

2 posts by 2 authors in: Forums > CMS Builder
Last Post: May 15, 2014   (RSS)

By gregThomas - May 15, 2014

Hi Craig, 

It's not possible to add a CC via a field in the e-mail templates section, but you can add a CC to a e-mail template before it's sent in the sendMessage function, here is an example of how this can be done:

  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/greg/www/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  //Create the appropriate headers from a e-mail template
  $emailHeaders = emailTemplate_loadFromDB(array(
    'template_id'  => 'THIS-IS-A-TEST',
    'placeholders' => array(
      'user.num'         => "enter value",
      'user.email'       => "enter value",
      'resetUrl'         => "enter value",
    //'your_placeholder' => "your value", // add new placeholders here
    )
  ));

  //Add CC to e-mail headers.
  $emailHeaders['headers']['CC'] = 'test@example.com';

  //Send the message
  $mailErrors = sendMessage($emailHeaders);
  if ($mailErrors) { die("Mail Error: $mailErrors"); }

So this should add a CC to the e-mail address set in $emailHeaders['headers']['CC'], which is test@example in this example.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com