How to send a letter to symfony to help swift mailer

  • I'd like to send a letter from the locol server using a swiftmailer and a gmail to symfony. These are code fragments.



    namespace MailerBundle\Controller;

    use Symfony\Bundle\FrameworkBundle\Controller\Controller;

    class DefaultController extends Controller
    public function indexAction()
    $Request = $this->getRequest();
    if($Request->getMethod()=="POST") {
    $name = $Request->get('name');
    $email = $Request->get('email');
    $subject =$Request->get('subject');
    $message = $Request->get('message');
    $message = \Swift_Message::newInstance()
    ->setBody('ExampleBundle:Default:mail.html.twig', 'text/html');

    Send the message

        return $this-&gt;render('MailerBundle:Default:index.html.twig');


    transport: %dev_mailer_transport%
    host: %dev_mailer_host%
    username: %dev_mailer_user%
    password: %dev_mailer_password%
    spool: { type: memory }

    This file is auto-generated during the composer install

    database_port: null
    database_name: symfony
    database_user: root
    database_password: null
    mailer_transport: smtp
    mailer_user: null
    mailer_password: null
    secret: 3rw23ewre343ewrew3434rwrew34343wre

    Mail setup for development environment

    dev_mailer_transport: gmail
    dev_mailer_host: null
    dev_mailer_password: password

    Mail setup for production environment

    prod_mailer_transport: smtp
    prod_mailer_host: localhost
    prod_mailer_user: null
    prod_mailer_password: null

    But somehow it's not working, it's been overprotected. Help!

  • Maybe it's a two-factor copying problem on your record. gmail♪ In this case, it will be necessary. individual password for application and use it Parameter mailer_password

    Also the recipe book. symfony I'll see you. I don't know.

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2