$_SESSION['email'] = $hook->getValue('email'); /* (off the top of my head. May not be quite correct) */$email = $_SESSION['email'];
I think your best bet is to get the data with $hook->getValue() in the custom redirect hook and save it as variables in the $_SESSION array.
$_SESSION['email'] = $hook->getValue('email'); /* (off the top of my head. May not be quite correct) */
Then you can retrieve the values in a snippet on page A or page B (using a Register preHook on page B to set the placeholders):
$email = $_SESSION['email'];
You could also use FormItRetriever, but I think the $_SESSION approach is a lot easier to implement.
Sending an email is pretty straightforward. There's example code at the end of this page.
Quote from: BobRay at Aug 16, 2016, 04:00 PMI think your best bet is to get the data with $hook->getValue() in the custom redirect hook and save it as variables in the $_SESSION array.
$_SESSION['email'] = $hook->getValue('email'); /* (off the top of my head. May not be quite correct) */
Then you can retrieve the values in a snippet on page A or page B (using a Register preHook on page B to set the placeholders):
$email = $_SESSION['email'];
You could also use FormItRetriever, but I think the $_SESSION approach is a lot easier to implement.
Sending an email is pretty straightforward. There's example code at the end of this page.
Bob - Using QuickEmail snippet - can I define a Chunk to use for the message body of the email? I need to pass PHP variables into it and mix it with some plain HTML elements...?
$modx->mail->address('bcc', '[email protected]');You don't need to use the snippet, just the code at the end. BCC should work fine.
I think this is what you need:
$modx->mail->address('bcc', '[email protected]');
$props = array(
'debug' => '0',
'hideOutput' => '0',
'message' => $FailEmailMessage,
'subject' => 'Email title',
'to' => '[email protected]',
'bcc' => '[email protected]',
'fromName' => 'Dave',
'emailSender' => '[email protected]',
'replyTo' => '[email protected]',
'html' => '1',
'failureMessage' => '<br /><h3 style="color:red">Mail Failed</h3>',
'successMessage' => '<br /><h3 style ="color:green">Mail reported successful</h3>',
'errorHeader' => '<br />Mail error:',
'smtpErrorHeader' => '<br />SMTP server report:',
);
$output = $modx->runSnippet('QuickEmail',$props);
return $output;
$cc = $modx->getOption('cc', $sp, '');
$bcc = $modx->getOption('bcc', $sp, '');if (! empty ($cc)) {
$modx->mail->address('cc', $cc);
}
if (!empty ($bcc)) {
$modx->mail->address('bcc', $bcc);
}