Exemple #1
0
 /**
  * Register the mailer.
  *
  * @return void
  */
 protected function register()
 {
     if (!$this->app->bound('view')) {
         $this->app['view'] = new ViewFactory();
     }
     $this->registerSwiftMailer();
     $this->mailer = new Mailer($this->app['view'], $this->app['swift.mailer'], $this->app['events']);
     $this->setMailerDependencies();
     $from = $this->app['config']['mail.from'];
     if (is_array($from) && isset($from['address'])) {
         $this->mailer->alwaysFrom($from['address'], $from['name']);
     }
     $to = $this->app['config']['mail.to'];
     if (is_array($to) && isset($to['address'])) {
         $this->mailer->alwaysTo($to['address'], $to['name']);
     }
 }
 /**
  * send.
  *
  * @param string          $slug
  * @param array           $data
  * @param \Closure|string $callback
  *
  * @return void
  */
 public function send($slug, $data, $closure)
 {
     $view = $this->getView($slug);
     $attributes = $this->getAttributes($slug);
     if (empty($attributes->from_address) === false) {
         $this->mailer->alwaysFrom($attributes->from_address, $attributes->from_name);
     }
     $sended = $this->mailer->send($slug, $data, $closure);
     return $sended;
 }