Alert Record Saved 2nd email
8 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 12, 2019 (RSS)
By osga - April 10, 2019
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
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,
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,
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!