ID: 50025 User updated by: wooptoo at gmail dot com Reported By: wooptoo at gmail dot com -Status: Feedback +Status: Closed Bug Type: Streams related Operating System: Linux x86_64 PHP Version: 5.3.0 New Comment:
Thanks lbarnaud. It seems that i have to fgets() everything the server sends for this to work. It's ok though. Previous Comments: ------------------------------------------------------------------------ [2009-10-27 23:33:04] [email protected] For each SMTP command you send, the server send you a reply (e.g. "200 ok"). Before enabling TLS, you need to read everything that was sent unencrypted by the server. ------------------------------------------------------------------------ [2009-10-27 22:28:38] [email protected] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2009-10-27 20:23:50] wooptoo at gmail dot com Description: ------------ You have to fgets() the output from the socket after STARTTLS or stream_socket_enable_crypto() won't work on SMTP. This is on SMTP. I didn't test on other protocols. Why is the fgets() necessary? Reproduce code: --------------- <?php $conn = fsockopen($server, $port, $errno, $errstr, $timeout); fputs($conn, 'HELO localhost'."\r\n"); fputs($conn, 'STARTTLS'."\r\n"); // why is this necessary? : fgets($conn); stream_socket_enable_crypto($conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); fputs($conn, 'HELO localhost'."\r\n"); ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50025&edit=1
