Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

fsockopen issue

Posted on 2014-03-06
6
Medium Priority
?
418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 300 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 300 total points
ID: 39912330
Just curious - have you tried SMTP on port 25?
0
Vim Reference Guide

Vim is a powerful text editor favored by many sysadmins and developers - here are some commands that you'll want to keep in your back pocket!

 

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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

704 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