Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

fsockopen issue

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
Thomanji
Asked:
Thomanji
  • 4
3 Solutions
 
Dan CraciunIT ConsultantCommented:
The manual says you need OpenSSL support installed.
Can you check if it's installed and configured properly?

HTH,
Dan
0
 
ThomanjiAuthor Commented:
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
 
Ray PaseurCommented:
Just curious - have you tried SMTP on port 25?
0
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.

 
ThomanjiAuthor Commented:
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
 
ThomanjiAuthor Commented:
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
 
ThomanjiAuthor Commented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now