public function __construct(Mailer $mailer = null) { if (!isset($mailer)) { $mailer = Mailer::fromConfig(); } $this->mailer = $mailer; }
<?php $app = (require __DIR__ . '/../bootstrap/start.php'); $mail = new \CatLab\Mailer\Models\Mail(); $to = new \CatLab\Mailer\Collections\ContactCollection(); $to[] = '*****@*****.**'; $to[] = '*****@*****.**'; $mail->setTo($to); $mail->setFrom('*****@*****.**'); $mail->setSubject('This is a test'); $mail->setText('This is an example text message.'); \CatLab\Mailer\Mailer::getInstance()->send($mail);
<?php // Initialize router $router = new \Neuron\Router(); $mailer = \CatLab\Mailer\Mailer::fromConfig(); return $router;
public function sendConfirmationEmail(Module $module) { return; $template = new Template('CatLab/Accounts/mails/confirmation.phpt'); $template->set('user', $this); $mail = new Mail(); $mail->setSubject('Email verification'); $mail->setTemplate($template); $mail->getTo()->add($this->getEmail()); $mail->setFrom(Config::get('mailer.from.email')); Mailer::getInstance()->send($mail); }
public static function sendMail($subject, $html, $email, $toName = "", $fromName = null, $fromEmail = null, $ccMyself = true, $isHtml = true) { $mailer = \CatLab\Mailer\Mailer::fromConfig(); $mail = new \CatLab\Mailer\Models\Mail(); if (defined('MAILER_FROM')) { $from = new \CatLab\Mailer\Models\Contact(); $from->setEmail(MAILER_FROM); if ($fromName) { // Set name. $from->setName($fromName); } $mail->setFrom($from); } if (isset($fromEmail)) { $replyTo = new \CatLab\Mailer\Models\Contact(); $replyTo->setEmail($fromEmail); if ($fromName) { $replyTo->setName($fromName); } $mail->setReplyTo($replyTo); } //$mail->ConfirmReadingTo = $myself->getEmail (); $to = $mail->getTo(); $to[] = \CatLab\Mailer\Models\Contact::fromMixed($email)->setName($toName); if (isset($fromName) && isset($fromEmail) && $ccMyself) { $cc = $mail->getCc(); $cc[] = \CatLab\Mailer\Models\Contact::fromMixed($fromEmail)->setName($fromEmail); } $mail->setSubject($subject); if ($isHtml) { $mail->setBody($html); } else { $mail->setText($html); } $mailer->send($mail); }