Solved

fsockopen issue

Posted on 2014-03-06
6
390 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 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

15 Experts available now in Live!

Get 1:1 Help Now