I’m trying to do a similar thing but with no joy!
I have a ‘Copy me in’ checkbox, when checked I want it to be like setting &ccsender to 1. I’ve tried passing the field value in with the parameter like &ccsender=`[+copy+]` and a script in &eFormOnBeforeMailSent to set copy to 0 if not 1, but this sends out ccsender email in both situations even though the copy field is being adjusted!
So I’ve followed advice above and it’s sending empty email:
<?php
// use with &eFormOnMailSent=`mailOut` in eForm
if( !function_exists('mailOut') ) {
function mailOut(&$fields) {
# send user a copy of the report
if($fields['copy'] == 'yes' && $fields['email']) {
global $modx, $from, $fromname, $subject, $report, $attachments;
# include PHP Mailer
include_once "manager/includes/controls/class.phpmailer.php";
$mail = new PHPMailer();
$mail->IsMail();
$mail->CharSet = $modx->config['modx_charset'];
$mail->IsHTML(true);
$mail->From = $from;
$mail->FromName = $fromname;
$mail->Subject = $subject;
$mail->Body = $report;
AddAddressToMailer($mail,"to",$fields['email']);
AttachFilesToMailer($mail,$attachments);
if(!$mail->send()) return 'CCSender: ' . $_lang['ef_mail_error'] . $mail->ErrorInfo;
}
return true;
}
}
return '';
?>
So it’s not finding the vars declared as global and you mention accessing these in the $modx->event->params array. Could you clarify how I would do this please?
Thanks