Hello,
I try to send email within a function in Processor.
Tried to use adapted code from Bob
private function mailnow(){
$email_content = $this->getProperty('emlContent');
$email_to = $this->getProperty('email');
if (!$this->modx->services->has('mail')) {
$this->modx->services->add('mail', new modPHPMailer($this->modx));
}
$mail = $this->modx->services->get('mail');
$mail->set(modMail::MAIL_BODY, $email_content);
$mail->set(modMail::MAIL_FROM, $this->modx->getOption('pp_emailFromService'));
$mail->set(modMail::MAIL_FROM_NAME, $this->modx->getOption('pp_emailFromServiceName'));
$mail->set(modMail::MAIL_SUBJECT, $this->modx->lexicon('eml_subject'));
$mail->address('to', $email_to);
$mail->setHTML(true);
if (!$mail->send()) {
$this->modx->log(1,'An error occurred while trying to send the email: ' . $mail->mailer->ErrorInfo);
return $this->modx->error->failure($this->modx->lexicon('eml_error'));
}else{
$mail->reset();
return true;
}
}
But gets error
Fatal error: Uncaught Error: Class “customer\processors\customers\modMail” not found in
I used class via
use MODX\Revolution\Mail\modPHPMailer;
What is wrong?
Thank you in advance.
bye
Chris