在Symfony2中使用gmail发送电子邮件时发生错误

时间:2015-03-05 19:15:14

标签: symfony gmail mailer

我有使用gmail发送电子邮件的问题。当我在我的服务器上测试表单时,邮件工作正常,但在将网站移动到另一个提供商错误之后

INFO - Matched route "my_frontend_default_index" (parameters: "_controller": "My\FrontendBundle\Controller\DefaultController::indexAction", "_route": "my_frontend_default_index")
ERROR - Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "tomasz.zalewski01@gmail.com" using 1 possible authenticators

my parameters.yml

parameters:
mailer_transport: gmail
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: 'tomasz.zalewski01@gmail.com'

我的config.yml

swiftmailer:
   transport: gmail
   host:      smtp.gmail.com
   username:  'tomasz.zalewski01@gmail.com'
   password:  'password'

有人知道问题在哪里?

1 个答案:

答案 0 :(得分:0)

首先,为什么不在配置中使用参数键?你根本不需要触摸配置。保留为:

swiftmailer:
    transport:  %mailer_transport%
    host:       %mailer_host%
    username:   %mailer_user%
    password:   %mailer_password%
    port:       %mailer_port%
    encryption: %mailer_encrypt%

然后为你的parameters.yml使用:

parameters:
    # ...
    mailer_transport: gmail
    mailer_host:      ~
    mailer_user:      your_gmail_username
    mailer_password:  your_gmail_password
    mailer_port:      465

正如http://symfony.com/doc/current/cookbook/email/gmail.html

中所述
相关问题