连接超时 Symfony2 Swiftmailer 和 Outlook

Connection timeout Symfony2 Swiftmailer and Outlook

当我想通过适用于 Symfony2 的 Swiftmailer 使用 Outlook 发送电子邮件时出现连接超时...

Connection could not be established with host smtp-mail.outlook.com [Connection timed out #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);

对我有用的是 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 服务器地址。