Ejemplo n.º 1
0
 /**
  * Transform contact.
  * @param $value
  * @param $index
  */
 public function transformContact($value, $index)
 {
     if (!$this[$index] instanceof Contact) {
         $contact = Contact::fromMixed($value);
         $this[$index] = $contact;
     }
 }
Ejemplo n.º 2
0
 /**
  * @param Contact $from
  * @return self
  */
 public function setFrom($from)
 {
     $from = Contact::fromMixed($from);
     $this->from = $from;
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * @param Contact $contact
  * @return array
  */
 private function getContact(Contact $contact)
 {
     return array('email' => $contact->getEmail());
 }
Ejemplo n.º 4
0
 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);
 }