Getting carried away with this plugin business.
Here's an improved version with configuration parameters for :
which plugin event, to email address, email subject & chunk name.
Plugin code :
$e = &$modx->Event;
if($e->name == ''.$piEvent.'') {
$pageid = $_POST['id'];
$pagetitle = $_POST['pagetitle'];
$editor = $modx->getLoginUserID() ;
$editedby = $modx->db->getValue('SELECT `username` FROM `modx_manager_users` WHERE `id` = 1');
$message = $modx->getChunk(''.$tplChunk.'');
$message = str_replace("[+id+]", $_POST['id'], $message);
$message = str_replace("[+pagetitle+]", $_POST['pagetitle'], $message);
$message = str_replace("[+editedby+]", $editedby, $message);
$sender = $modx->config['emailsender'];
if(!mail("$to", $subject, $message, "From: ".$sender."\r\n"."X-Mailer: Content Manager - PHP/".phpversion()))
{
$modx->logEvent(1,3,"$to, $subject, $message, $sender", "Email");
}
return true;
}
Plugin configuration settings :
&to=Mail To;string;someone@somewhere.com &piEvent=Plug In Event;string;OnDocFormSave &tplChunk=Chunk Name;string;Emailer &subject=Email Subject;string;Who's been messing with my site?