fsockopen returns 'bool(false)' from browser but 'resource(4) of type (stream)' from command line

By : air4x
Source: Stackoverflow.com

I cannot send mail in sugarcrm. Suagrcrm sends mail with phpmailer using SMTP. I have identified that the error occurs when an attempt to open a socket connection using fsockopen is made. The call to fsockopen returns boolean (false).
The arguments given to fsockopen are 5 variables containing the following values 'mail.example.com'(hostname), 25(port), ''(errno), ''(errstr), 10(timeout)

The error message is
Code: 10107 Reply: A system call that should never fail has failed.

The error code is present in microsoft website under 'Windows Sockets Error Codes' and is partly explained as:
Returned when a provider does not return SUCCESS and does not provide an extended error code. Can indicate a service provider implementation error.

The issue occurs when I call the script from a broswer. If I execute the script from command line, fsockopen returns a resource.

Program Info:
Windows XP
Apache/2.0.63 (Win32) mod_ssl/2.0.63 OpenSSL/0.9.8i PHP/5.2.8 Server
PHP Version => 5.2.8

Can anyone suggest any possible solutions for this issue. Thanks in advance for any suggestion.

By : air4x


When running under windows, try port 587 instead of 25!

By : ChrisH

The error was caused due to the presence of a firewall in the system used as the web server. It worked fine when I uninstalled the firewall.

By : air4x

This video can help you solving your question :)
By: admin