disabled function or other Problem. Help needed

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
Jörg Wuest
Forum Newbie
Posts: 5
Joined: Wed Dec 04, 2013 8:15 am

disabled function or other Problem. Help needed

Post by Jörg Wuest »

Hello,

I need to know which function could perhaps disabled by my Hoster.
After a Domain Move my Hoster had set some function's to diabled for security reasons. I can talk to my Hoster Support to enable this function's but i need to know what function this are.

Code: Select all

    Warning: stream_set_blocking() expects parameter 1 to be resource, null given in 
    /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/StreamBuffer.php on line 265
     
    Warning: stream_set_timeout() expects parameter 1 to be resource, null given in 
    /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/StreamBuffer.php on line 269


    Fatal error:
    Uncaught exception 'Swift_TransportException' with message 'Expected response code 220 but got code "", with message ""'
    in /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php:386
    Stack trace:
    #0 /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php(291):
        Swift_Transport_AbstractSmtpTransport->_assertResponseCode('', Array)
    #1 /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php(119):
        Swift_Transport_AbstractSmtpTransport->_readGreeting()
    #2 /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Mailer.php(80):
        Swift_Transport_AbstractSmtpTransport->start()
    #3 /var/www/web128032/html/includes/register1.php(203): Swift_Mailer->send(Object(Swift_Message))
    #4 /var/www/web128032/html/index.php(42): include('/var/www/web128...')
    #5 {main} thrown in /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/AbstractSmtpTransport.php on line 386

Greetings Jörg.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: disabled function or other Problem. Help needed

Post by Weirdan »

Check /var/www/web128032/html/Swift-4.2.2/lib/classes/Swift/Transport/StreamBuffer.php, line 265 to see what the first argument to the function call is, then find where the variable is assigned. There you'll find one of the functions producing a stream, like fopen or stream_socket_client (there are many various functions that may produce a stream). That function is what's failing.
Jörg Wuest
Forum Newbie
Posts: 5
Joined: Wed Dec 04, 2013 8:15 am

Re: disabled function or other Problem. Help needed

Post by Jörg Wuest »

Sure had the same thoughts, beetween a figured out that proc_open is disabled.

Code: Select all

echo function_exists('proc_open') ? "Yep, that will work" : "Sorry, that won't work";
Ouput was: "Sorry, that won't work"

Now i have to wait for my Hoster-Support then i can tell you if it now works. Ive seen many Posts an Question with the same Problem and Trace but no solutions (the most of them change the Hoster)

Anyway hier is the StreamBuffer.php:
https://github.com/swiftmailer/swiftmai ... Buffer.php
I was not able to say for sure which Ressource will be filled in the func stream_set_blocking()
But i think it could be an disabled proc_open()
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: disabled function or other Problem. Help needed

Post by Weirdan »

See https://github.com/swiftmailer/swiftmai ... r.php#L257 - it's stream_socket_client that returned null.
Jörg Wuest
Forum Newbie
Posts: 5
Joined: Wed Dec 04, 2013 8:15 am

Re: disabled function or other Problem. Help needed

Post by Jörg Wuest »

Yes you are right!

hell what did my hoster all disabled? men i wrote him since 3 or 4 days first mail() then other now proc_open and stream_socket_client

Code: Select all

echo function_exists('stream_socket_client') ? "2 Yep, that will work" : "2 Sorry, that won't work";

$fp = stream_socket_client("tcp://www.example.com:80", $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    fwrite($fp, "GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\n\r\n");
    while (!feof($fp)) {
        echo fgets($fp, 1024);
    }
    fclose($fp);
}

Output:
2 Sorry, that won't work
Warning: stream_socket_client() has been disabled for security reasons in /var/www/web128032/html/Backend/templates/admin.tpl on line 24
But i wonder why trows not this Errormessage to lines later?
https://github.com/swiftmailer/swiftmai ... r.php#L260

I think the support will hate me soon :D
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: disabled function or other Problem. Help needed

Post by Weirdan »

But i wonder why trows not this Errormessage to lines later?
That's because it only executes that branch if the function returned false (and you got null, as all disabled function implicitly return null). The code clearly does not expect the function to be disabled.
Jörg Wuest
Forum Newbie
Posts: 5
Joined: Wed Dec 04, 2013 8:15 am

Re: disabled function or other Problem. Help needed

Post by Jörg Wuest »

Ah yes ok i thought 0 == false. Ok know i unterstand.
Ok i wait for Request from my Support and will give feedback if solved or not (so can other participate from our Thread).

Thx you between!

greetings Jörg.
Jörg Wuest
Forum Newbie
Posts: 5
Joined: Wed Dec 04, 2013 8:15 am

Re: disabled function or other Problem. Help needed

Post by Jörg Wuest »

So the Problem is solved.

To solve this trace you have to enable mail() and stream_socket_client()
My Hoster did not enable proc_open() because of Security Risks! But Swiftmailer (i think so) have build a Fallback for this function.

Thank you Weirdan for your Help.

Edit: fsockopen() was also enabled earlier, not sure if swiftmailer works with zhis function.
Post Reply