【问题标题】:Connection timeout Symfony2 Swiftmailer and Outlook连接超时 Symfony2 Swiftmailer 和 Outlook
【发布时间】:2016-03-03 10:24:12
【问题描述】:

当我想通过 Swiftmailer for Symfony2 使用 Outlook 发送电子邮件时,连接超时...

无法与主机 smtp-mail.outlook.com 建立连接 [连接超时 #110]

我在这里和互联网上阅读了很多东西,但没有任何效果...... 但是我尝试使用该帐户设置 Thunderbird,并且它起作用了(软件使用 STARTTLS 而不是 TLS)。

这是我的参数:

dev_mailer_transport: smtp
dev_mailer_host: smtp-mail.outlook.com
dev_mailer_port: 587
dev_mailer_user: USERNAME
dev_mailer_password: PASSWORD

这是我的配置:

swiftmailer:
    encryption: tls
    auth_mode: login

这是用于发送电子邮件的代码:

$message = \Swift_Message::newInstance()
                        ->setSubject($subject)
                        ->setFrom("no-reply@test.com")
                        ->setTo($data["email"])
                        ->setBody(nl2br($content), 'text/html');
$this->container->get('mailer')->send($message);

【问题讨论】:

    标签: php symfony email outlook swiftmailer


    【解决方案1】:

    对我有用的是 config.yml:

    swiftmailer:
        transport:          "%mailer_transport%"
        host:               "%mailer_host%"
        port:               "%mailer_port%"
        username:           "%mailer_user%"
        password:           "%mailer_password%"
        encryption:         "%mailer_encryption%"
        delivery_address:   "%mailer_delivery_adress%"
    

    和parameters.yml:

    mailer_transport: smtp
    mailer_host: smtp.office365.com
    mailer_port: 587
    mailer_user: user@example.com
    mailer_password: mypassword
    mailer_encryption: tls
    mailer_delivery_adress: someadress@example.com
    

    请注意,Microsoft 在邮件服务器的大小、频率和负载方面有一些限制。

    我的示例是针对 Outlook365 而不是 Outlook.com,但唯一的区别是确切的 smtp 服务器地址。

    【讨论】:

    • 谢谢!经过一番研究,我发现 Cloud9(一个开发环境,在云端)通过 smtp 阻止邮件。似乎只有“gmail”传输方法被授权。我将在服务器上部署我的应用程序并直接尝试我的代码。
    猜你喜欢
    • 2014-10-16
    • 2011-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-10
    • 2016-02-19
    • 1970-01-01
    相关资源
    最近更新 更多