简体   繁体   English

Symfony2:尝试使用Swiftmailer发送电子邮件时出错

[英]Symfony2: error trying to send an email with Swiftmailer

I have the following issue when I try to send an email with swift in a Symfony2 project : Exception occurred while flushing email queue: Expected response code 220 but got code "", with message ". 当我尝试在Symfony2项目中发送带有swift的电子邮件时出现以下问题:刷新电子邮件队列时出现异常:预期的响应代码220但是获得了代码“”,带有消息“。

I am in localhost and I try to use a mail of my host OVH. 我在localhost,我尝试使用我的主机OVH的邮件。 Here is my config.yml: 这是我的config.yml:

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    auth_mode: "%mailer_auth_mode%"
    host:      "%mailer_host%"
    port:      "%mailer_port%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }

And my parameters.yml: 和我的parameters.yml:

# This file is auto-generated during the composer install
parameters:
    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: null
    database_name: ********
    database_user: root
    database_password: null
    mailer_transport: mail
    mailer_auth_mode: login
    mailer_host:  ns0.ovh.net
    mailer_port: 587
    mailer_user: contact@******.com
    mailer_password: **********
    locale: fr
    secret: ThisTokenIsNotSoSecretChangeIt

Thank you 谢谢

What version of SwiftMailer did you install? 你安装了什么版本的SwiftMailer? The mail transport is deprecated from SwiftMailer 5.4.5. 邮件传输已从SwiftMailer 5.4.5弃用。

Starting from SwiftMailer 5.4.5, the mail transport is deprecated and will be removed in version 6. Consider using another transport like smtp, sendmail or gmail. 从SwiftMailer 5.4.5开始,邮件传输已弃用,将在版本6中删除。请考虑使用其他传输,如smtp,sendmail或gmail。

You can see more info at this links: 您可以在以下链接中查看更多信息:

https://symfony.com/doc/current/reference/configuration/swiftmailer.html#transport https://symfony.com/doc/current/reference/configuration/swiftmailer.html#transport

http://symfony.com/doc/current/email.html http://symfony.com/doc/current/email.html

You need to change the mailer_transport . 您需要更改mailer_transport Try with this config, editing the port, encryption, host... 尝试使用此配置,编辑端口,加密,主机...

parameters.yml parameters.yml

parameters:
    mailer_transport: smtp
    mailer_host: smtp.example.com
    mailer_user: user@example.com
    mailer_password: my_password
    mailer_port: 587
    mailer_encryption: tls

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM