I am using the Login plugin, and on the register snippet I am trying to get the two files that the user has uploaded in the file inputs and attach them to an email using modmail in a post hook. The problem is that as of now the files are not attaching to the email. Here is my snippet call:
<?php
$values = $hook->getValues();
$email = $values['email'];
$company = $values['companyName'];
$liability = $values['liabilityFile'];
$comp = $values['compFile'];
$message = 'Hi, a new User signed up: '.$company . ' with email '. $email .'.';
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,'send@email.com');
$modx->mail->set(modMail::MAIL_FROM_NAME,'Registration Files');
$modx->mail->set(modMail::MAIL_SUBJECT,"{$company} Files");
$modx->mail->address('to','receive@email.com');
$modx->mail->setHTML(true);
$modx->mail->mailer->addAttachment($liability);
$modx->mail->mailer->addAttachment($comp);
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();
/* tell our snippet we're good and can continue */
return true;
Im wondering is anyone has any input.
Thanks in advance.