dashiwa / php52-backports

Automatically exported from code.google.com/p/php52-backports
Other
0 stars 0 forks source link

Error to send mail with phpmailer from joomla 1.5.xx and smtp host != localhost #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When send mail to host not localhost using phpmailer the fuction fsockopen 

Joomla 1.5.xx use this script to send mails

and show this error:

SMTP Error! Could not connect to SMTP host.

I think the problem is the patch in php52-backports/ext/sockets/sockets.c

@@ -246,16 +246,13 @@
 }
 /* }}} */

-static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, 
struct sockaddr *la TSRMLS_DC) /* {{{ */
+static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, 
struct sockaddr *la, socklen_t *la_len TSRMLS_DC) /* {{{ */
 {
-       socklen_t       salen;
        php_socket      *out_sock = (php_socket*)emalloc(sizeof(php_socket));

        *new_sock = out_sock;
-       salen = sizeof(*la);
-       out_sock->blocking = 1;

-       out_sock->bsd_socket = accept(in_sock->bsd_socket, la, &salen);
+       out_sock->bsd_socket = accept(in_sock->bsd_socket, la, la_len);

        if (IS_INVALID_SOCKET(out_sock)) {
                PHP_SOCKET_ERROR(out_sock, "unable to accept incoming connection", errno);
@@ -263,6 +260,10 @@
                return 0;
        }

+       out_sock->error = 0;
+       out_sock->blocking = 1;
+       out_sock->type = la->sa_family;
+
        return 1;
 }
 /* }}} */
@@ -723,9 +724,10 @@
    Accepts a connection on the listening socket fd */
 PHP_FUNCTION(socket_accept)
 {
-       zval                            *arg1;
-       php_socket                      *php_sock, *new_sock;
-       struct sockaddr_in      sa;
+       zval                             *arg1;
+       php_socket                       *php_sock, *new_sock;
+       php_sockaddr_storage sa;
+       socklen_t                        sa_len = sizeof(sa);

        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) {
                return;
@@ -733,13 +735,10 @@

        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);

-       if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr *) &sa 
TSRMLS_CC)) {
+       if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, 
&sa_len TSRMLS_CC)) {
                RETURN_FALSE;
        }

-       new_sock->error = 0;
-       new_sock->blocking = 1;
-
        ZEND_REGISTER_RESOURCE(return_value, new_sock, le_socket);
 }
 /* }}} */

Original issue reported on code.google.com by inod...@gmail.com on 10 Sep 2012 at 4:26

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It's joomla specific issue, I reproduced this if use smtp host is not 
localhost, but socket functions works fine (see 
http://www.php.net/manual/en/function.socket-connect.php This will print the 
banner from a true 'telnet' server - connect to port 25)
I'm working on this

Original comment by svyatosl...@gmail.com on 10 Sep 2012 at 6:24

GoogleCodeExporter commented 8 years ago
hmm, I have tested this again and send mail as via SMTP mailer trought other 
server and found no issue

Original comment by svyatosl...@gmail.com on 10 Sep 2012 at 6:31

GoogleCodeExporter commented 8 years ago
The test your telnet.php and run ok, I search more and I think the bug is the 
older phpmailer used in Joomla 1.5.

the error is same to this:

http://stackoverflow.com/questions/5294751/using-gmails-outgoing-smtp-from-php-u
sing-tls

Close this bug, php is OK!

Original comment by inod...@gmail.com on 10 Sep 2012 at 8:12

GoogleCodeExporter commented 8 years ago

Original comment by svyatosl...@gmail.com on 11 Sep 2012 at 2:49