cakephp/cakephp — pull request #3994 by ndm2 (2014-07-16 15:48:35+00:00)
Title: 3.0 - Persistent SMTP connections

As already mentioned in #3013, I'd like to suggest support for persistent SMTP connections. They are especially useful when batch sending mails (newsletters, mailing lists, notifications, etc...), as most hosters do apply certain rate limiting like a maximum of x connections per y time.

Contrary to how it's done in the `Socket` class, this patch introduces a `connected()` method to test for an active connection. I think it's cleaner and easier to test/mock if necessary, and I'm wondering if it would be a good idea to expose something similar on the `Socket` class too, ie wrap `$connected` into a method?

I'm not sure if there are any conventions regarding this, but it would allow mocking and using expectations instead of making use of `Socket::$connected` (as can be seen in this patch's tests), also there seems to be no reason why the outside world should be able to change the exposed connection state without actually affecting the connection.

This is kind of a question for a new ticket, but since it would affect this patch's tests I thought I'd ask right here.