Ejemplo n.º 1
0
 public function sendMail($formValues)
 {
     //        dump($formValues);
     //        die();
     //
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/emailTemplates/' . $this->templateFilename);
     $template->registerFilter(new Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $attachments = array();
     if (isset($formValues['cv']) && $formValues['cv'] instanceof Nette\Http\FileUpload) {
         if ($formValues['cv']->isOk()) {
             $attachments[$formValues['cv']->getName()] = $formValues['cv']->getContents();
         }
     }
     unset($formValues['cv']);
     $template->values = $formValues;
     //        echo $template;
     //        die();
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->from)->setSubject($this->subject)->addTo($this->to)->setHtmlBody($template);
     if ($attachments) {
         foreach ($attachments as $name => $content) {
             $mail->addAttachment($name, $content);
         }
     }
     //        foreach ($tos as $to) {
     //            $mail->addTo($to);
     //        }
     $mail->send();
 }
Ejemplo n.º 2
0
 public function sendTestEmailSmtp($from, $to, $settings)
 {
     $mailer = new SmtpMailer($settings);
     $message = new Message();
     $message->setFrom($from);
     $message->addTo($to);
     $message->setBody('Tatami mail test');
     $message->setMailer($mailer);
     $message->send();
 }