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 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 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' ] ) ; }
Test a mail address

@param  Request $request
@return RedirectResponse
Test a mail address