Skip to content

Commit 14e4467

Browse files
committed
Update fMailbox.php handling 5.6+ Security
As of PHP version 5.6 there is much stricter security checking being done on various levels. Flourish's excellent Mailbox class unfortunately isn't up-to-date enough to handle the new restrictions by default. This fix is simply a fallback to allow for its previous level of functionality. It bypasses the new security implementations that PHP 5.6 brings to the table, but users of Gmail's mail server, or users of shared hosting will be able to continue to use this library with the class as expected. (It has to do with domain mismatch.)
1 parent 60f80f1 commit 14e4467

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

fMailbox.php

+25-8
Original file line numberDiff line numberDiff line change
@@ -965,13 +965,30 @@ private function connect()
965965

966966
fCore::startErrorCapture(E_WARNING);
967967

968-
$this->connection = fsockopen(
969-
$this->secure ? 'tls://' . $this->host : $this->host,
970-
$this->port,
971-
$error_number,
972-
$error_string,
973-
$this->timeout
974-
);
968+
if ($this->secure) {
969+
$this->connection = stream_socket_client(
970+
'tls://' . $this->host . ':' . $this->port,
971+
$error_number,
972+
$error_string,
973+
$this->timeout,
974+
STREAM_CLIENT_CONNECT,
975+
stream_context_create(array(
976+
'ssl' => array(
977+
'verify_peer' => false,
978+
'verify_peer_name' => false,
979+
'disable_compression' => true,
980+
)
981+
))
982+
);
983+
} else {
984+
$this->connection = fsockopen(
985+
$this->host,
986+
$this->port,
987+
$error_number,
988+
$error_string,
989+
$this->timeout
990+
);
991+
}
975992

976993
foreach (fCore::stopErrorCapture('#ssl#i') as $error) {
977994
throw new fConnectivityException('There was an error connecting to the server. A secure connection was requested, but was not available. Try a non-secure connection instead.');
@@ -1522,4 +1539,4 @@ private function write($command, $expected=NULL)
15221539
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15231540
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
15241541
* THE SOFTWARE.
1525-
*/
1542+
*/

0 commit comments

Comments
 (0)