Alert Record Saved 2nd email

By daniel - April 10, 2019

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
Technical Lead
interactivetools.com

By osga - April 10, 2019

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

By daniel - April 10, 2019

Hi Jim, 

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

Thanks,

Daniel
Technical Lead
interactivetools.com

By Djulia - April 11, 2019 - edited: April 11, 2019

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

By osga - April 11, 2019

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, 2019 - edited: April 11, 2019

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

By osga - April 12, 2019

Thanx for the assistance Djuila. 

Put in this new code and BOOM! Works great!

The Plugin is now EXACLTY what we need!