Symfony 在生产环境中发送电子邮件 [英] Symfony Send email in production environment

查看:134
本文介绍了Symfony 在生产环境中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 prod 环境中发送电子邮件,但它不起作用...我收到此日志:

I am trying to send email in prod environment but it doesn't work... I am getting this log:

[2014-06-30 09:37:54] request.CRITICAL:未捕获的 PHP 异常Swift_TransportException:预期的响应代码为 250,但得到了代码530",带有消息530 5.7.0 必须首先发出 STARTTLS 命令.o2sm28357522wia.16 - gsmtp "" atC:\xampp\htdocs\UniDocs\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php第 386 行 {"exception":"[object] (Swift_TransportException: Expected响应代码 250 但得到代码530",消息为530 5.7.0 必须"首先发出 STARTTLS 命令.o2sm28357522wia.16 - gsmtp\r\n\" atC:\xampp\htdocs\UniDocs\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php:386)"}[]

[2014-06-30 09:37:54] request.CRITICAL: Uncaught PHP Exception Swift_TransportException: "Expected response code 250 but got code "530", with message "530 5.7.0 Must issue a STARTTLS command first. o2sm28357522wia.16 - gsmtp "" at C:\xampp\htdocs\UniDocs\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php line 386 {"exception":"[object] (Swift_TransportException: Expected response code 250 but got code \"530\", with message \"530 5.7.0 Must issue a STARTTLS command first. o2sm28357522wia.16 - gsmtp\r\n\" at C:\xampp\htdocs\UniDocs\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php:386)"} []

然而,在开发中它正在工作......

However, in dev it is working...

我的配置如下:

config_dev.yml:

swiftmailer:运输:smtp加密:sslauth_mode:登录主机:smtp.gmail.com用户名:myemail@gmail.com密码:mypass

swiftmailer: transport: smtp encryption: ssl auth_mode: login host: smtp.gmail.com username: myemail@gmail.com password: mypass

config.yml:

swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%

parameters.yml:

mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_user: myemail@gmail.com
mailer_password: mypass

我还有一个问题...,在 web/app.php 中我是否必须写 $kernel = new AppKernel('prod', false);$kernel =new AppKernel('prod', true);??

I also have another question..., in web/app.php do I have to write $kernel = new AppKernel('prod', false); or $kernel = new AppKernel('prod', true);??

推荐答案

我在 Symfony2 中使用我的 Gmail 帐户发送电子邮件,并且我指定了一些您没有指定的参数.以下是我的配置:

I've used my Gmail account to send emails in Symfony2, and I specify some parameters which you have not specified. Below is my configuration:

config.yml:

swiftmailer:
    transport: %mailer_transport%
    encryption: %mailer_encryption%
    auth_mode:  %mailer_auth_mode%
    host:      %mailer_host%
    username:  %mailer_username%
    password:  %mailer_password%
    spool:     { type: memory }

parameters.yml:

mailer_transport:  smtp
mailer_encryption: ssl
mailer_auth_mode:  login
mailer_host:       smtp.gmail.com
mailer_username: myusername@gmail.com
mailer_password: mypassword

与你的第二个问题有关,原文是

Related with your second question, the original line is

$kernel = new AppKernel('prod', false);

如果将其更改为 true,则可以在生产模式下显示错误消息,因为 AppKernel 构造的第二个参数指示调试模式.

If you change this to true, error messages can be showed in production mode, because the second parameter of the AppKernel construct indicates the debug mode.

这篇关于Symfony 在生产环境中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆