[solved] fsockopen() function problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Douldoul
Forum Newbie
Posts: 3
Joined: Thu Dec 09, 2010 3:05 am

[solved] fsockopen() function problem

Post by Douldoul »

Hi there :)
I have a problem with a function of PHP. I can't understand why it cannot work, and that a problem for my project :banghead:.

The context :
I have Joomla and want it to send email via the option "SMTP server". It's not working and the return is "Can't connect to smtp host". I had searched in google for that problem and all the solutions I found didn't work for me. So I decided to go into the code to see what happened. The problem occurs when the code call to the method "fsockopen()", a built-in PHP method. This method say that the connection to the host timed out.
Where it becomes funny : I can connect and send email with this host, with exact same parameters with a mail client (Evolution), on the same machine (so it's not a problem of opened port or something else).

The method is :

Code: Select all

fsockopen($host, $port, $errno, $errstr, $tval);
The used parameters and error returned :

Code: Select all

$host : ssl://smtp.laposte.net. 
$port :25. 
$errno :110. 
$errstr :Connection timed out. 
$tval :10
Some technical information :
PHP Version : 5.2.14
Sockets Support : enabled
[edit] OpenSSL :enabled
OS : Ubuntu 10.10 under a virtual machine (VMWare)
Port : port 25 (smtp) is open on the virtual machine AND on the host of the virtual machine

If someone had an idea how this function work and why it cannot connect, it will help me A LOT :drunk: ,
Thanks in advance,
Douldoul
Last edited by Douldoul on Thu Dec 09, 2010 9:11 am, edited 1 time in total.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: fsockopen() function problem

Post by Darhazer »

The ssl version is most likely at port 465, not 25
P.S. try telneting the host on the same port, so you can check if this is not really a network issue
Douldoul
Forum Newbie
Posts: 3
Joined: Thu Dec 09, 2010 3:05 am

Re: fsockopen() function problem

Post by Douldoul »

Hi Darhazer and thanks for the reply :)
I had missed that thing, smtp secure port is 465.
But I telnet the server and the connection succeed with the port 465 :( (But finally it's normal, as Evolution (my email client) succeed to connect to the host from the same PC)

Another idea?
Douldoul
Forum Newbie
Posts: 3
Joined: Thu Dec 09, 2010 3:05 am

Re: fsockopen() function problem

Post by Douldoul »

Ok,
I tried to put the correct port into joomla...and what a surprise :dubious: ...it works....So I'm a big dumb, doing a lot of investigation for merely nothing and, finally, many thanks Darhazer :D
Post Reply