【问题标题】:During send email using gmail in Symfony2 error occured在 Symfony2 中使用 gmail 发送电子邮件期间发生错误
【发布时间】:2015-05-07 07:03:42
【问题描述】:

我无法使用 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

我的参数.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'

有人知道问题出在哪里吗?

【问题讨论】:

    标签: symfony gmail mailer


    【解决方案1】:

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

    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中所建议的那样

    【讨论】:

    • 使用 stis 设置我收到错误:ParameterNotFoundException:您请求了一个不存在的参数“mailer_port”。您的意思是:“mailer_host”?
    • 你可以将mailer_port添加到你的参数文件中,你使用的是什么版本的symfony和swiftmailer?
    • 我访问了http://www.google.com/accounts/DisplayUnlockCaptcha,并在此邮件发送电子邮件后
    • @Tomasz 使用此回复 google.com/accounts/DisplayUnlockCaptcha 编辑您的问题,因为它也解决了我的问题。
    猜你喜欢
    • 2017-09-09
    • 2023-03-08
    • 2016-09-02
    • 1970-01-01
    • 2021-10-09
    • 2013-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多