Solved

fsockopen issue

Posted on 2014-03-06
6
394 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 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 39912330
Just curious - have you tried SMTP on port 25?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

830 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