[[!FormIt? &hooks=`spam,email,hook.emailNotify,FormItSaveForm,redirect` &spamEmailFields=`youremail` &submitVar=`contactUs-submit` &emailTpl=`contactUs.form.emailTpl` &emailSubject=`[Contact Us]` &emailTo=`[[++site.dev.email]]` &redirectTo=`144` &store=`1` &validate=` youremail:email:required, workemail:blank, yourname:required, comments:required` ]] form html here.
<?php
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$log_prefix ="CONTACT: ";
$message = "
Thank You for your interest in ExecuService. A Customer Service Representative will contact you within the next business day. Have a safe day!
Regards,
ExecuService Marketing
";
$to_email = $hook->getValue('youremail');
$modx->log(modX::LOG_LEVEL_INFO, $log_prefix.$to_email);
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,'[email protected]');
$modx->mail->set(modMail::MAIL_FROM_NAME,'ExecuService Admin');
$modx->mail->set(modMail::MAIL_SENDER,'ExecuService Admin');
$modx->mail->set(modMail::MAIL_SUBJECT,'[ExecuService] Thank you!');
$modx->mail->address('to',$to_email);
$modx->mail->setHTML(true);
$sent = $modx->mail->send();
if ($sent) {
$output = 'Mail sent';
} else {
$output = 'An error occurred while trying to send the email';
}
$modx->log(modX::LOG_LEVEL_ERROR,$log_prefix.$output);
// $modx->mail->reset();
/* tell our snippet we're good and can continue */
return true;
This question has been answered by pixelstation. See the first response.
$output = 'An error occurred while trying to send the email: ' . $modx->mail->mailer->ErrorInfo ;
$output = 'An error occurred while trying to send the email: ' . $modx->mail->getError() ;
// $modx->mail->set(modMail::MAIL_SENDER,'ExecuService Admin'); $modx->mail->set(modMail::MAIL_SENDER,'[email protected]');