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


Symfony2: error trying to send an email with Swiftmailer

当我尝试在Symfony2项目:刷新电子邮件队列时发生异常:应为响应代码220,但得到的代码为",消息为"。

我在localhost,我尝试使用主机OVH的邮件。这是我的配置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 }

还有我的参数。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

感谢

您安装了什么版本的SwiftMailer?SwiftMailer 5.4.5不赞成使用邮件传输。

从SwiftMailer 5.4.5开始,邮件传输已被弃用,并将在版本6中删除。考虑使用另一种传输方式,如smtp、sendmail或gmail。

您可以在以下链接中看到更多信息:

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

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

您需要更改mailer_transport。尝试使用此配置,编辑端口、加密、主机。。。

参数.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