Advertisement
krot

MODX modMail

Aug 25th, 2017
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. $message = $modx->getChunk('myEmailTemplate');
  2.  
  3. $modx->getService('mail', 'mail.modPHPMailer');
  4. $modx->mail->set(modMail::MAIL_BODY,$message);
  5. $modx->mail->set(modMail::MAIL_FROM,'me@example.org');
  6. $modx->mail->set(modMail::MAIL_FROM_NAME,'Johnny Tester');
  7. $modx->mail->set(modMail::MAIL_SUBJECT,'Check out my new email template!');
  8. $modx->mail->address('to','user@example.com');
  9. $modx->mail->address('reply-to','me@xexample.org');
  10. $modx->mail->setHTML(true);
  11.  
  12. if (!$modx->mail->send()) {
  13.     $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$modx->mail->mailer->ErrorInfo);
  14. }
  15.  
  16. $modx->mail->reset();
  17. /*https://docs.modx.com/revolution/2.x/developing-in-modx/advanced-development/modx-services/modmail*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement