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

Hey guys.

We were looking for a way to have CMS Builder send us an email when a writer posts. Added in the Alert Record Saved plugin and then fixed the error via another post in here. Works great now. But. we'd like it to send to two email addresses.

We played around trying to add in a 'cc' field but that does not seem to work. This seems like it should be so easy. uggh.

I know that Alert Record Saved is not an Interactive Tools plugin, but is there a line of code we can stick in this thing to make the plugin send to developerEmail as a CC?

Thanx

Jim

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