Search code examples
symfonyemailfosuserbundlesend

symfony2 gmail send email not working


i try to send email with the fosuserbundle but it's not working . this is my file configuration :

config.yml

swiftmailer:
     transport:  "%mailer_transport%"
     encryption: "%mailer_encryption%"
     host:       "%mailer_host%"
     username:   "%mailer_user%"
     password:   "%mailer_password%"


fos_user:
     db_driver: orm
     firewall_name: main
     user_class: Session\UserBundle\Entity\User
     registration:
         confirmation:
             enabled: true

parameters.yml

  parameters:
      database_driver: pdo_mysql
      database_host: 127.0.0.1
      database_port: null
      database_name: ensaj
      database_user: root
      database_password: null
      mailer_encryption: ssl
      mailer_auth_mode: login
      mailer_transport: gmail
      mailer_host: smtp.gmail.com
      mailer_user: xxxxxxx@gmail.com
      mailer_password: 1xxxxxxx

      locale: fr
      secret: 2ca840346e95efa11df5c5f12a572ea5dcf64e83

any idea please ; by the way i change my gmail configuration to active pop and imap but no way . and sometimes i have a message to my email that notice :blocked connection attempt


Solution

  • for me it works like:

    swiftmailer:
        transport: "%mailer_transport%"
        username:  "%mailer_user%"
        password:  "%mailer_password%"
    

    when using mailer_transport == gmail

    optionally you may have to allow that account beeing used for your app, https://support.google.com/accounts/answer/6010255