symfony2 gmail 发送电子邮件不工作

symfony2 gmail send email not working

我尝试使用 fosuserbundle 发送电子邮件,但它不起作用。 这是我的文件配置:

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

有什么想法吗? 顺便说一句,我将我的 gmail 配置更改为活动 pop 和 imap,但没有办法。 有时我会在我的电子邮件中收到一条通知消息:已阻止连接尝试

对我来说,它的工作方式如下:

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

使用 mailer_transport == gmail

您可能需要选择允许该帐户用于您的应用程序, https://support.google.com/accounts/answer/6010255