/**
  * Handle the command.
  *
  * @param ContactFormBuilder $builder
  * @param MessageBag         $messages
  * @param Mailer             $mailer
  */
 public function handle(ContactFormBuilder $builder, MessageBag $messages, Mailer $mailer)
 {
     // Validation failed!
     if ($builder->hasFormErrors()) {
         return;
     }
     // Delegate these for now.
     $view = $this->dispatch(new GetMessageView($builder));
     $data = $this->dispatch(new GetMessageData($builder));
     // Build the message object.
     $message = function (Message $message) use($builder) {
         $this->dispatch(new BuildMessage($message, $builder));
     };
     // Send the email.
     $mailer->send($view, $data, $message);
     // If there are any failures, report.
     if (count($mailer->failures()) > 0) {
         $messages->error($builder->getFormOption('error_message', 'anomaly.plugin.contact::error.send_message'));
     } else {
         // Otherwise, show success.
         $messages->success($builder->getFormOption('success_message', 'anomaly.plugin.contact::success.send_message'));
     }
     // Clear the form!
     $builder->resetForm();
 }
Esempio n. 2
0
 /**
  * Handle the command.
  *
  * @param Mailer     $mailer
  * @param Repository $config
  * @return bool
  */
 public function handle(Mailer $mailer, Repository $config)
 {
     $path = $this->dispatch(new GetResetPasswordPath($this->user, $this->redirect));
     $mailer->send('anomaly.module.users::message/reset', compact('user', 'path'), function (Message $message) use($config) {
         $message->subject('Reset your password')->to($this->user->getEmail(), $this->user->getDisplayName())->from($config->get('mail.from.address', 'noreply@localhost'));
     });
     return empty($mailer->failures());
 }
Esempio n. 3
0
 /**
  * Send a simple email
  *
  * For more complex emails you might write another method
  *
  * @throws MailException Throws an exception containing further information as message
  * @return void
  */
 public function sendMail()
 {
     try {
         $this->mail->send($this->view, $this->data, function ($message) {
             $message->from($this->from['address'], $this->from['name']);
             $message->to($this->to['address'], $this->to['name'])->subject($this->subject);
         });
         if ($this->mail->failures() != array()) {
             throw new MailException($this->mailErrorMessage);
         }
     } catch (Swift_TransportException $e) {
         $this->handleTransportExceptions($e);
     }
 }
Esempio n. 4
0
 /**
  * Get the array of failed recipients.
  *
  * @return array 
  * @static 
  */
 public static function failures()
 {
     return \Illuminate\Mail\Mailer::failures();
 }
Esempio n. 5
0
 /**
  * Get the array of failed recipients.
  *
  *
  */
 public function failures()
 {
     return $this->mailer->failures();
 }