-
Notifications
You must be signed in to change notification settings - Fork 56
Zend\Mail doesn't work with Smtp transport via SSL connection .. #130
Comments
Are you sure this is due to SlmQueue? Does it work when you do not use SlmQueue but directly invoke the email service inside the HTTP dispatch loop? A possible cause is the difference in configuration for CLI and cgi/fpm/mod-php. They both hold different php.ini files and this can cause a mismatch between a CLI and non-CLI call. |
I use the same Mailer module in my application without using SlmQueue and everything works. |
@BnitoBzh you can create a CLI route and dispatch a controller. There you invoke your mail service and test what is happening. You simply start the request the same as with SlmQueue:
What can be wrong in CLI mode is something with the ssl module in php. I have no idea since I have never run into this issue, but I have been using Soflomo\Mail (which is a service wrapper around Zend\Mail) with SlmQueue fine. |
I created a test controller for a test on the command line. Emails go well, while in parallel emails always have the SSL problem through SlmQueue Job. |
I did the test with my own Mailer module and with the module Soflomo\Mail |
@BnitoBzh my concern is, SlmQueue does nothing with SSL. I think it's because two jobs are executed directly after each other and something in the HTTP traffic is bugging the handshake. I do not now everything about SSL, but you can perform a "short" handshake for a 2nd connection, so you don't need to negotiate for the complete process. You keep a kind-of session id and that is reused among further connections. I guess in this process the bug is hidden, so somehow in a second connection, php cannot handle your connection well.
|
The problem is still not resolved and I have not been able to solve it yet. But we've tried to use swiftmailer instead of zend mail, and everything is working like a charm now. I suggest to switch to it if you have similar problem, and can switch library. |
Thanks for the update @mstrychalski. I'll close this for now though; because this repo does nothing with SSL or mail and I think the problem lies outside this repo |
@mstrychalski This could be a problem with the maximum connection lifetime. The SMTP Server will close the connection if nothing is sent over it after a while. Even if you constantly send a ping or NOOP, there is a maximum connection lifetime setting for most servers. Meaning they'll close the connection regardless. What you have to do with zend-mail is recreate the connection every so often, see my PR here: zendframework/zend-mail#172 We're using zend-mail together with SlmQueue and it works. You just have to guess (?) the connection timelimit of your SMTP server. It wasnt properly document in ours... |
Mm. What about introducing a section in this repo that gives some general hints about problems with long-connectivity @MatthiasKuehneEllerhold? We know this is also a problem with database connections 🤔. If you like the idea; would you be willing to add a PR regarding the SSL connection to a section in the docs? |
This problem is not specific to SSL connections because the same happens with HTTP connections. The error message is different on a plain HTTP connection:
But I'm not sure if its the same error that @mstrychalski describes. He switched libraries and the error was gone. I dont know if his new library has the auto-reconnect feature that zend-mail misses (until my PR is merged). Adding some text to the documentation will help for sure. I'll try to whip up something and will need your input (english isnt my main language ;)). |
No problem @MatthiasKuehneEllerhold, mention me when you have something and I'll gladly give feedback :). |
Issue #177 is similar. Let's use that to keep track of this effort. |
I use this module to send my emails in the background via Zend / Mail, but my SMTP server allows only SSL connections.
After a few minutes of inactivity to send email, the tail always returns the same error with a message "SSL broken pipe".
Impossible to miss even creating a Mailer Service on the fly, which returns me an error like this: "SSL operation failed with code 1 OpenSSL Error messages: error: 1409F07F: SSL routines: SSL3_WRITE_PENDING: bad write retry in ..."
I think this is due to the permanent php process, so that the mail function with Zend/Mail can not work with SlmQueue...
The text was updated successfully, but these errors were encountered: