8 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 12   (RSS)

Hi Jim,

You should be able to add a CC by adding the following to the array of email options:

   'headers' => array(
      "CC" => "cc@example.com",
    ),

Let me know if that does the trick!

Thanks,

Daniel
PHP Programmer
interactivetools.com

Thanx Daniel.

Unfortunately, that easy fix did not work. Tried a few variations of that prior to posting.

Just tried it again with the double quotes. Still sends the "To" email, but not the CC.

:>(

Jim

Hi Jim, 

Could you copy/paste the whole mail configuration array here (including the CC) for me to have a look?

Thanks,

Daniel
PHP Programmer
interactivetools.com

By Djulia - April 11 - edited: April 11

Hi Jim,

Can you try this :

$emailHeaders = emailTemplate_load(array(
  ...
));

$emailHeaders['headers']['CC'] = 'test@test.com';
$mailErrors = sendMessage($emailHeaders);
if ($mailErrors) { die("Mail Error: $mailErrors"); }

Thanks,
Djulia

Hi Djulia...

Can you tell us where this would belong in the code?

Here is the original code we currently have on the page:

// send email on save
function _plugin_alertRecordSaved() {
global $SETTINGS, $CURRENT_USER, $tableName, $isNewRecord, $oldRecord;

//
$emailTemplate = "alert-record-saved.mel.php";
$emailHeaders = emailTemplate_load(array(
'template' => $emailTemplate,
'template' => saved_sendAlertMessage_pluginDir() . "/$emailTemplate",
'subject' => '[CMSB :: Alert New Record Is Saved]',
'from' => $SETTINGS['adminEmail'],
'to' => $SETTINGS['adminEmail'],
'CC' => "osgajim@gmail.com",
'placeholders' => array(
'username' => $CURRENT_USER['username'],
'email' => $CURRENT_USER['email'],
'tableName' => $tableName,
'isNewRecord' => $isNewRecord,
'recordNum' => intval(@$_REQUEST['num']),
'title' => htmlspecialchars(@$_REQUEST['title']),
'oldTitle' => htmlspecialchars($oldRecord['title']),
),
'disabled' => false,
'logging' => false,
));
$mailErrors = sendMessage($emailHeaders);
if ($mailErrors) { die("Mail Error: $mailErrors"); }
}

By Djulia - April 11 - edited: April 11

Hi Jim,

Can you try this :

// send email on save
function _plugin_alertRecordSaved() {
	global $SETTINGS, $CURRENT_USER, $tableName, $isNewRecord, $oldRecord;

	//
	$emailTemplate = "alert-record-saved.mel.php";
	$emailHeaders  = emailTemplate_load(array(
		'template' => $emailTemplate,
		'template' => saved_sendAlertMessage_pluginDir() . "/$emailTemplate",
		'subject'  => '[CMSB :: Alert New Record Is Saved]',
		'from'     => $SETTINGS['adminEmail'],
		'to'       => $SETTINGS['adminEmail'],
		'placeholders' => array(
			'username'    => $CURRENT_USER['username'],
			'email'       => $CURRENT_USER['email'],
			'tableName'   => $tableName,
			'isNewRecord' => $isNewRecord,
			'recordNum'   => intval(@$_REQUEST['num']),
			'title'       => htmlspecialchars(@$_REQUEST['title']),
			'oldTitle'    => htmlspecialchars($oldRecord['title']),
		),
		'disabled' => false,
		'logging' => false,
	));

	$emailHeaders['headers']['CC'] = 'test@test.com';
	$mailErrors = sendMessage($emailHeaders);
	if ($mailErrors) { die("Mail Error: $mailErrors"); }
}

Thanks,

Djulia

Thanx for the assistance Djuila. 

Put in this new code and BOOM! Works great!

The Plugin is now EXACLTY what we need!