PHP Fsockopen check port 25 - php

I have written a code to check port 25 of one of my local server . The smtp server is running on the server, but when i check with fsockopen, returns a connection refused error . So how i check whether SMTP is down or up using a simple php code .

Are the php script and the smpt on the same machine? Have you checked the connection with telnet?
telnet your.local.server 25
Generally "Connection refused" means, what it says ;)
smtp server is not running, or
your server is not reachable (firewall?)

It's better to write your server detail such as OS
check your firewall ,maybe it refuses your connection
And check connection with :
telnet your-server 25

Related

Remote SQL Server configuration : which ports?

I have a VPS running Windows Server 2012 in a public IP. I've installed SQL Server on it and changed the firewall allowing all incoming / outcoming TCP connections on port 1433.
However when i try to connect on this server remotely from a PHP application, i get the error below :
SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist
Is there any other ports / protocols i should allow to the connection work ?
When i try to telnet the server on the port 1433 :
Connecting To xxx.xxx.xxx.xxx...Could not open connection to the host,
on port 1433: Connect failed
This solved my issue !
Enable remote connections for SQL Server:
a) In SQL Server Configuration Manager, expand SQL Server Network Configuration, and then click Protocols for <instancename>.
b) In the details pane, right-click one of the available protocols, and then click Properties.
c) To enable the TCP/IP protocol (or named pipes) for remote connections, set the Enabled box to Yes.

How to open port 25 to send email from localhost on windows

I need one help.I need to send email using Localhost on windows.When i typed the below command and check.
telnet localhost 25 it gave me the following result.
Connecting To localhost...Could not open connection to the host, on port 25: Connect failed
Please help me to open this port and send email successfully.
You have to install an email server on your machine. You can try hMailServer

PHP and MSSQL 2012 Express database on other server - connection error

As the title, i have problem with connection from Linux server to server with MSSQL 2012 Express.
Server with MSSQL:
Windows 8
MSSQL 2012 Express, turned on and running correctly;
IP on dyndns.org (ports on the router are correctly forwarded, 1433 is open and 'listening');
Windows firewall is disabled;
Router firewall is disabled;
Server with Linux:
PHP 5.2;
Script:
$server = 'xxxxxxx.dyndns.org';
$username = 'xxxxxxx';
$password = 'xxxxxxx';
$database = 'xxxxx';
if (mssql_connect($server, $username, $password))
{
echo "CONNECTION SUCCESS!";
}
else
{
echo "CONNECTION FAIL";
}
Result:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: xxxxxxx.dyndns.org in (....) on line 8
Connection failed: A connection attempt failed because the connected party did
not properly respond after a period of time, or established connection failed
because connected host has failed to respond Connection failed: A connection
attempt failed because the connected party did not properly respond after a
period of time, or established connection failed because connected host has failed
to respond xxx.xxx.xxx.xxx:1433
I had this exact same error just now. With me it was TCP Dynamic port being used, which was not allowed through the firewall. Since it's a dynamic port, it's hard to allow just that port.
You can check by restarting your SQL server instance, and then look in the Event Viewer what port SQL Server is listening on if you have the same issue.
Open the SQL Server Configuration Manager
Then open SQL Server Network Configuration > Protocols for SQLEXPRESS(or whatever db engine you're using) > TCP/IP > IP Adresses
Make sure that in your IP adresses your TCP Port is set to the correct port you wish to use(Not entirely sure this is needed, but doesn't hurt)
Now when you come to the last item, IPAll, set TCP Dynamic ports to empty. This will disable dynamic port selection, and fill in the TCP Port you wish to use under TCP Port
Open the windows advanced firewall and allow your selected port to accept connections, if there isn't already a rule for it.
You should add a rule under Inbound rules, name it SQL port or something. Under Action "Allow the connection"
On the tab protocols and ports select Protocol type: "TCP", Local port "specific ports" "1433"(or your port number), Remote port "All ports"
and on scope any IP Adresses for local, for remote you can either choose "Any" or add a list of ip's you wish to add
Then go to your SQL Server Management Studio and hit right click on the server instant and select restart to restart the database server.
You'll get two prompts, one from uac. Then one from sql server if you're really sure you wish to restart. The second one can vanish behind other windows and can take some time to appear. So after hitting restart, be patient and don't click on stuff except the uac message.

class.phpmailer.php SMTP -> ERROR: Failed to connect to server

I've been using class.phpmailer.php for some time but recently it stop working on my web server.
It is still working on my home computer but I guess that it's because I didn't update xampp.
The error returned is:
php SMTP -> ERROR: Failed to connect to server: A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond. (10060)
I've also used this class eukhost and it sends the email with no errors.
I'm now going debugging class.phpmailer.php to see what is wrong.
But before I start, I would like to know if someone got this problem ans solved it.
If this had been working and now has recently stopped, it could be a temporary issue, or some settings for the mail server have been changed and you now need to update your settings.
The error message is telling you that it could not connect to the mail server. Socket error 10060 is a general operation timed out message.
You need to verify that the SMTP host and port numbers being used by phpmailer are correct. You should from another machine (or the same system running PHP) be able to telnet your-mail-server-here.com 25 where 25 represents the port number.
If you can't connect to the server, then the mail server is down or the hostname or port have changed. If you can connect from other systems but not from your PHP server, it is possible your IP has been blocked from the mail server, or a local/remote firewall are preventing your connection.
Hope that helps.

Mysql Connect to external/remote server outside the VLAN

I am trying to connect to an external mysql server from a computer which is inside a vlan where my application will run. The remote server is not a member of the vlan. The following is what I have tried so far.
Mysql Port forwarding from my vlan server
ssh -L 3306:my-vlan-server-ip:3306 user-at-external-server#external-server-ip
In this case I get a ssh timeout message.
Tried to do it directly from my php mysql_connect I get mysql error #111 yet I have already edited the my.cnf as:
#skip-networking
bind-address =my-vlan-server-ip
My php db connect script
<?php
$conn=mysql_connect("external-server-ip","user","pass");
if($conn)
{
echo "success";
}
else
{
echo "fail";
}
?>
Kindly someone help.Let me know where I am going wrong. Thanks.
If I understand you correctly you are running the ssh client on the vlan server (=my-vlan-server-ip)?
The local tunnelling (-L) basicly forwards the first port to the given port on the given address, i.e -L 80:someserver:8080 forwards port 80 on the local machine to port 8080 on someserver... so if you want to connect to 3306 on the remote server via ssh you do:
ssh -L 3306:external-server-ip:3306 user-at-external-server#external-server-ip
(or just -L 3306:localhost:3306, localhost will then refer to the server to which you are connecting, ie external-server-ip)
localhost:3306 is then forwarded to external-server-ip:3306
in the php script running on my-vlan-server-ip you then connect to localhost:3306, which is then forwarded to external-server-ip by ssh...

Categories