Skip to content

Instantly share code, notes, and snippets.

@dubrod
Created November 30, 2018 00:47
Show Gist options
  • Save dubrod/05cf58c5a0c8e55dd962dc74cfff1062 to your computer and use it in GitHub Desktop.
Save dubrod/05cf58c5a0c8e55dd962dc74cfff1062 to your computer and use it in GitHub Desktop.
https://rtfm.modx.com/revolution/2.x/developing-in-modx/advanced-development/modx-services/modmail
/* modx mail service */
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,$from);
$modx->mail->set(modMail::MAIL_FROM_NAME,'Quick Quote');
$modx->mail->set(modMail::MAIL_SUBJECT,'Lease Quote #'.$id.'');
$modx->mail->address('to','sales@theleaseoutlet.dsmessage.com');
//$modx->mail->address('reply-to','me@xexample.org');
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
}
$modx->mail->reset();
/* /eof modx mail service */
///examples
$modx->getOption('emailsender');
$message = "Form error on page: <strong>" . $_POST["page"] . "</strong><br>
at element: <strong>" . $_POST["element"] . "</strong><br>
in browser: <strong>" . $_POST["browser"] . "</strong>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment