I'm working with a script that should do the same thing but I have a bit to go until it is finished.
Look at the FormIt email-hook to see how it is done there.
You can load PHPMailer with this command:
/* load mail service */
$modx->getService('mail', 'mail.modPHPMailer');
and then use syntax like this to send the mail:
/* set email main properties */
$modx->mail->set(modMail::MAIL_BODY, $message);
$modx->mail->set(modMail::MAIL_FROM, $emailFrom);
$modx->mail->set(modMail::MAIL_FROM_NAME, $emailFromName);
$modx->mail->set(modMail::MAIL_SENDER, $emailFrom);
$modx->mail->set(modMail::MAIL_SUBJECT, $subject);
$modx->mail->address('to', $emailTo, $emailToName);
/* send email */
$sent = $modx->mail->send();
if (!$sent) {
$modx->log(modX::LOG_LEVEL_ERROR, '[Error sending email] ' . print_r($modx->mail->mailer->ErrorInfo, true));
}
you can also use all functions from PHPMailer in this way:
$modx->mail->mailer->AnyPHPMailerFunction();