private function notifyUserSetupEmail(Request $request, $displayName, $email)
    {
        $logger = $this->app['logger.system'];
        $mailer = $this->app['mailer'];
        $transport = $this->app['swiftmailer.spooltransport'];

        // Create a welcome email
        $mailHtml = $this->app['twig']->render(
            '@bolt/email/firstuser.twig',
            ['context' => ['sitename' => $this->getOption('general/sitename')]]
        );

        $name = $this->getOption('general/mailoptions/senderName', $this->getOption('general/sitename'));
        $sendermail = $this->getOption('general/mailoptions/senderMail', 'bolt@' . $request->getHost());
        $from = [$sendermail => $name];
        $email = $this->getOption('general/mailoptions/senderMail', $email);
        try {
            /** @var Message $message */
            $message = $mailer
                ->createMessage('message')
                ->setSubject(Trans::__('general.bolt-new-site-set-up'))
                ->setFrom($from)
                ->setReplyTo($from)
                ->setTo([$email   => $displayName])
                ->setBody($mailHtml, 'text/html')
                ->addPart(preg_replace('/^[\t ]+|[\t ]+$/m', '', strip_tags($mailHtml)), 'text/plain')
                ->setPriority(Message::PRIORITY_HIGH);
        } catch (RfcComplianceException $e) {
            // Sending message failed. What else can we do, send via snailmail?
            $logger->critical("The email address set in 'mailoptions/senderMail' is not a valid email address.", ['event' => 'exception', 'exception' => $e]);

            return;
        }

        try {
            // Try and send immediately
            $failedRecipients = [];
            $mailer->send($message, $failedRecipients);
            $transport->getSpool()->flushQueue($this->app['swiftmailer.transport']);
        } catch (TransportException $e) {
            // Sending message failed. What else can we do, send via snailmail?
            $logger->error("The 'mailoptions' need to be set in app/config/config.yml", ['event' => 'config']);
        }
    }
private function notifyUserSetupEmail(Request $request, $displayName, $email)
    {
        $logger = $this->app['logger.system'];
        $mailer = $this->app['mailer'];
        $transport = $this->app['swiftmailer.spooltransport'];

        // Create a welcome email
        $mailHtml = $this->app['twig']->render(
            '@bolt/email/firstuser.twig',
            ['context' => ['sitename' => $this->getOption('general/sitename')]]
        );

        $name = $this->getOption('general/mailoptions/senderName', $this->getOption('general/sitename'));
        $sendermail = $this->getOption('general/mailoptions/senderMail', 'bolt@' . $request->getHost());
        $from = [$sendermail => $name];
        $email = $this->getOption('general/mailoptions/senderMail', $email);
        try {
            /** @var Message $message */
            $message = $mailer
                ->createMessage('message')
                ->setSubject(Trans::__('general.bolt-new-site-set-up'))
                ->setFrom($from)
                ->setReplyTo($from)
                ->setTo([$email   => $displayName])
                ->setBody($mailHtml, 'text/html')
                ->addPart(preg_replace('/^[\t ]+|[\t ]+$/m', '', strip_tags($mailHtml)), 'text/plain')
                ->setPriority(Message::PRIORITY_HIGH);
        } catch (RfcComplianceException $e) {
            // Sending message failed. What else can we do, send via snailmail?
            $logger->critical("The email address set in 'mailoptions/senderMail' is not a valid email address.", ['event' => 'exception', 'exception' => $e]);

            return;
        }

        try {
            // Try and send immediately
            $failedRecipients = [];
            $mailer->send($message, $failedRecipients);
            $transport->getSpool()->flushQueue($this->app['swiftmailer.transport']);
        } catch (TransportException $e) {
            // Sending message failed. What else can we do, send via snailmail?
            $logger->error("The 'mailoptions' need to be set in app/config/config.yml", ['event' => 'config']);
        }
    }
private function notifyUserSetupEmail ( Request $ request , $ displayName , $ email ) { $ logger = $ this -> app [ 'logger.system' ] ; $ mailer = $ this -> app [ 'mailer' ] ; $ transport = $ this -> app [ 'swiftmailer.spooltransport' ] ; // Create a welcome email $ mailHtml = $ this -> app [ 'twig' ] -> render ( '@bolt/email/firstuser.twig' , [ 'context' => [ 'sitename' => $ this -> getOption ( 'general/sitename' ) ] ] ) ; $ name = $ this -> getOption ( 'general/mailoptions/senderName' , $ this -> getOption ( 'general/sitename' ) ) ; $ sendermail = $ this -> getOption ( 'general/mailoptions/senderMail' , 'bolt@' . $ request -> getHost ( ) ) ; $ from = [ $ sendermail => $ name ] ; $ email = $ this -> getOption ( 'general/mailoptions/senderMail' , $ email ) ; try { /** @var Message $message */ $ message = $ mailer -> createMessage ( 'message' ) -> setSubject ( Trans :: __ ( 'general.bolt-new-site-set-up' ) ) -> setFrom ( $ from ) -> setReplyTo ( $ from ) -> setTo ( [ $ email => $ displayName ] ) -> setBody ( $ mailHtml , 'text/html' ) -> addPart ( preg_replace ( '/^[\t ]+|[\t ]+$/m' , '' , strip_tags ( $ mailHtml ) ) , 'text/plain' ) -> setPriority ( Message :: PRIORITY_HIGH ) ; } catch ( RfcComplianceException $ e ) { // Sending message failed. What else can we do, send via snailmail? $ logger -> critical ( "The email address set in 'mailoptions/senderMail' is not a valid email address." , [ 'event' => 'exception' , 'exception' => $ e ] ) ; return ; } try { // Try and send immediately $ failedRecipients = [ ] ; $ mailer -> send ( $ message , $ failedRecipients ) ; $ transport -> getSpool ( ) -> flushQueue ( $ this -> app [ 'swiftmailer.transport' ] ) ; } catch ( TransportException $ e ) { // Sending message failed. What else can we do, send via snailmail? $ logger -> error ( "The 'mailoptions' need to be set in app/config/config.yml" , [ 'event' => 'config' ] ) ; } }
Send a welcome email to test mail settings.

@param Request $request
@param string  $displayName
@param string  $email
Send a welcome email to test mail settings .