예제 #1
0
파일: Mail.php 프로젝트: frenchfrogs/mail
 /**
  * Generates a \Illuminate\Mail\Message template ready to send
  *
  * @param array $args = []
  * @return $this
  */
 public function generateMessage($args = [])
 {
     if (!empty($args)) {
         foreach ($args as $att => $v) {
             if (array_key_exists($att, get_object_vars($this))) {
                 $this->{$att} = $v;
             }
         }
     }
     $msg = new Message(new \Swift_Message());
     if ($this->hasFrom()) {
         $from = $this->getFrom();
         $msg->from($from[0], $from[1]);
     }
     if ($this->hasSender()) {
         $sender = $this->getSender();
         $msg->sender($sender[0], $sender[1]);
     }
     if ($this->hasTo()) {
         $to = $this->getTo();
         $msg->to($to[0], $to[1]);
     }
     if ($this->hasCc()) {
         $cc = $this->getCc();
         $msg->cc($cc[0], $cc[1]);
     }
     if ($this->hasBcc()) {
         $bcc = $this->getBcc();
         $msg->bcc($bcc[0], $bcc[1]);
     }
     if ($this->hasReplyTo()) {
         $reply_to = $this->getReplyTo();
         $msg->replyTo($reply_to[0], $reply_to[1]);
     }
     if ($this->hasSubject()) {
         $msg->subject($this->getSubject());
     }
     if ($this->hasAttach()) {
         foreach ($this->getAttach() as $attach) {
             $msg->attachData($attach[0], $attach[1], $attach[2]);
         }
     }
     if ($this->hasPriority()) {
         $msg->priority($this->getPriority());
     }
     $this->setMessage($msg);
     return $this;
 }