/**
  * Test a mail address
  *
  * @param  Request $request
  * @return RedirectResponse
  */
 public function sendMail(Request $request)
 {
     if (null === ($mail = $request->request->get('email'))) {
         $this->app->abort(400, 'Bad request missing email parameter');
     }
     if (!\Swift_Validate::email($mail)) {
         $this->app->abort(400, 'Bad request missing email parameter');
     }
     try {
         $receiver = new Receiver(null, $mail);
     } catch (InvalidArgumentException $e) {
         return $this->app->redirectPath('admin_dashboard', ['email' => 'not-sent']);
     }
     $mail = MailTest::create($this->app, $receiver);
     $this->deliver($mail);
     /** @var \Swift_SpoolTransport $spoolTransport */
     $spoolTransport = $this->app['swiftmailer.spooltransport'];
     /** @var \Swift_Transport $transport */
     $transport = $this->app['swiftmailer.transport'];
     $spoolTransport->getSpool()->flushQueue($transport);
     return $this->app->redirectPath('admin_dashboard', ['email' => 'sent']);
 }
 public function getMail()
 {
     return MailTest::create($this->getApplication(), $this->getReceiverMock(), $this->getEmitterMock(), $this->getMessage());
 }
Exemple #3
0
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $this->container['notification.deliverer']->deliver(Mail::create($this->container, new Receiver(null, $input->getArgument('email'))));
     return 0;
 }
Exemple #4
0
 /**
  * Test a mail address
  *
  * @param  Application      $app
  * @param  Request          $request
  * @return RedirectResponse
  */
 public function sendMail(Application $app, Request $request)
 {
     if (null === ($mail = $request->request->get('email'))) {
         $app->abort(400, 'Bad request missing email parameter');
     }
     if (!\Swift_Validate::email($request->request->get('email'))) {
         $app->abort(400, 'Bad request missing email parameter');
     }
     try {
         $receiver = new Receiver(null, $mail);
     } catch (InvalidArgumentException $e) {
         return $app->redirectPath('admin_dashbord', ['email' => 'not-sent']);
     }
     $mail = MailTest::create($app, $receiver);
     $app['notification.deliverer']->deliver($mail);
     $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']);
     return $app->redirectPath('admin_dashbord', ['email' => 'sent']);
 }