As I explained in my last article that we have to do some customization in Modx Revolution default functionality as per our requirement.
so to send mail in Modx Revolution externally, we have to add a piece of code.
By default, Modx Revolution uses a PhpMailer (modPHPMailer) to send a mail.and you can use it to send mail from any file or any external file of the Modx.
modPHPMailer is a class which extends the modMail class to provide an implementation for the open source PHPMailer class.and modMail is an abstract class so it can be extended to provide mail services for Modx Revolution
Some more articles for Modx:
Import Users in MODx
Logged in User in Modx
To setup other Resource as Homepage in Modx
Here,please have a look into the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $scriptProperties =array(); $modx->getService('mail', 'mail.modPHPMailer'); $modx->mail->set(modMail::MAIL_FROM, 'admin@modx.com'); $modx->mail->set(modMail::MAIL_FROM_NAME, 'admin'); $modx->mail->set(modMail::MAIL_SENDER, FromEmail);; $modx->mail->set(modMail::MAIL_SUBJECT, 'Some Subject'); $modx->mail->address('to', ToEmail, ToName); $modx->mail->address('reply-to', 'no-reply@domain.com'); $modx->mail->setHTML(true); //call send mail $sent = $modx->mail->send(); |
That’s it.The $scriptProperties is an array which contain properties for the snippet.Here,getService return a named service class instance like get the modPHPMailer service.
I hope this post will help you. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.
Comments (3)