Solved

fsockopen issue

Posted on 2014-03-06
6
384 Views
Last Modified: 2014-06-21
Hi,

I got a linux server running centos6. There is a problem in sending mails on xcart. So I made a little script to see if the basic mail is working but it does not.

<?php
 
//phpinfo();
$fp = fsockopen('tls://mailapp.domain.net', 587, $errno, $errstr, 15);
if (!$fp) {
    echo "port is closed or blocked";
} else {
    echo "port is open and available";
    fclose($fp);
}

?>

but I get Warning: fsockopen(): unable to connect to tls://mailapp.domain.net:587 (Connection timed out) in phpinfo.php on line 4

if I replace the tls://mailapp.dmni.net with smtp.gmail.com it does work.
I ensured the port is open.
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:587

mailapp.domain.net is on the same server I try to run the script and on my desktop mail client I can connect find to thge server using port 587.
I also tried with without tls:// and with ssl://

any ideas what this could be?

Best wishes,
Thomas
0
Comment
Question by:Thomanji
  • 4
6 Comments
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 100 total points
ID: 39911829
The manual says you need OpenSSL support installed.
Can you check if it's installed and configured properly?

HTH,
Dan
0
 

Author Comment

by:Thomanji
ID: 39911954
Hi Dan,

Thanks
Yes it is enabled and confirmed.

PHP 5.4 is compiled '--with-openssl'

In the php info I see

- Registered Stream Socket Transports      tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
- curl ssl yes
- imap ssl emabled
- openssl
OpenSSL support       enabled
OpenSSL Library Version       OpenSSL 1.0.0-fips 29 Mar 2010
OpenSSL Header Version       OpenSSL 1.0.0-fips 29 Mar 2010

- Phar Native OpenSSL support enabled

so it seems all is fine. However if I do without tls or ssl and just type in the domain than it does not work either. I tried port 587, 25, 465 noting works.
If I use localhost with 587 this does work.

Best wishes,
thomas
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 39912330
Just curious - have you tried SMTP on port 25?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Thomanji
ID: 39928277
Hi,

Yes,  I tried port 587, 25, 465 noting works.

The system is behind a NAT but these ports are open. Also mail from outlook or thundebird is working fine.

I did also find out that I can not telnet into SMTP either on the same server. This might have something to do with it.

telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mailapp.domain.net ESMTP
421 4.4.2 mailapp.domain.net Error: timeout exceeded
Connection closed by foreign host.

I am more and more suspecting a firewall issue but the ports are all open so it is real strange.

Any ideas anyone?

Best wishes,
Thomas
0
 

Accepted Solution

by:
Thomanji earned 0 total points
ID: 40138445
Hi,
Thank you all for the thoughts. However the issue was related to the DNS settings and the NAT set-up. So I do understand this was a hard question and could have gone deep. Still I appreciate your input and give 100 goodwill points for the responses.

Best wishes,
Thomas
0
 

Author Closing Comment

by:Thomanji
ID: 40148983
the issue was not resolved due to the 2 comments. I did assign some points for the effort to read the question but since after my last comment no one answered I decided that 100 points per comment is fair. If anyone would given a response after my last comment then I would have given this person the remaining points.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now