PHP Swiftmailer与Zoho smtp服务器不发送邮件


PHP Swiftmailer with Zoho smtp server not sending mail

我在Symfony2上使用Swiftmailer。我也在使用Zoho邮件来托管我的邮件服务器,我已经使用Zoho提供的smpt详细信息配置了Swiftmailer,但看起来有问题,因为引发了以下异常:

PHP Fatal error:  Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host 127.0.0.1 [Connection refused #111]'

我的parameters.yml文件看起来像:

parameters:
    mailer_transport: smtp
    mailer_host: smtp.zoho.com
    mailer_port: 465
    mailer_encryption: ssl
    mailer_user: my_username
    mailer_password: my_password
    mailer_authmode: plain

和我的配置yml:

swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    port:      "%mailer_port%"
    encryption: "%mailer_encryption%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    auth_mode: "%mailer_authmode%"
    spool:     { type: memory }

我已经使用telnet测试了连接,一切似乎都很好:

root:/# telnet smtp.zoho.com 465
Trying 74.201.154.90...
Connected to smtp.zoho.com.
Escape character is '^]'.

我错过了什么?

谢谢!

好吧,如果你的parameters.yml加载得很好,那么我想我知道问题的根源,我认为你的网络主机不允许ssl连接端口465,它拒绝连接,这就是错误111的意思,首先尝试使用端口587的TLS安全连接。如果你仍然想使用465尝试联系你的网络主机检查该端口。

编辑:

删除"应该修复

swiftmailer:
    transport: %mailer_transport%
    host:      %mailer_host%
    port:      %mailer_port%
    encryption: %mailer_encryption%
    username:  %mailer_user%
    password:  %mailer_password%
    auth_mode: %mailer_authmode%
    spool:     { type: memory }

将mailer_authmode:plain更改为mailer_authmode:login。

在尝试了所有解决方案(在我的开发和生产机器中)后,我尝试了PhpMailer。它工作得很好。

我认为问题出在SwiftMailer的代码中。

您需要登录zoho并设置特定于应用程序的密码。您可以在"安全性"->"双因素身份验证"下找到它。使用该密码而不是您的帐户密码。

请注意,Zoho Mail的免费计划不再提供IMAP/POP支持:

```
FREE PLAN
Up to 25 Users
5GB* /User, 25MB Attachment Limit
Webmail access only+. Single domain hosting.
```

+IMAP/POP支持仅适用于付费计划

https://www.zoho.com/workplace/pricing.html?src=zmail

旧的免费计划(2018年之前注册)似乎仍然支持IMAP/POP可用

来源:https://help.zoho.com/portal/community/topic/zoho-free-tier-pop-imap-activesync-no-longer-free