简体   繁体   中英

PHP Swiftmailer with Zoho smtp server not sending mail

I'm using Swiftmailer on a Symfony2. I'm also using Zoho mail to host my mail server and I have configured Swiftmailer using the smpt details provided by Zoho, but it looks like something is wrong because the following exception is thrown:

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

My parameters.yml file looks like:

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

and my config.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 }

I have tested the connection using telnet and everything seems to be alright:

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

What am I missing?

Thanks!

Well, if you parameters.yml is well loaded then i think i know the problem where it comes from, i think your webhost doesn't allow ssl connection port 465, it refuses the connection thats what the error 111 means, try first to connect using TLS security with port 587. If you still want to use 465 try contacting your web hosting to check that port.

Edit :

Remove the "" should fix it

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。

After trying with all the solutions (in my development and the production machine) I've tryied PhpMailer . It works perfectly.

I think the problem is in SwiftMailer's code.

You need to log into zoho and set up an application specific password. You can find it under Security -> Two Factor Authentication. Use that password instead of your account password.

Please note that Zoho Mail does not offer IMAP/POP support anymore with their free plan :

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

+IMAP/POP Support Available exclusively with the paid plans.

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

Old free plans (registered before 2018???) seem to still have IMAP/POP Support Available

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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