Failed to connect to mailserver at "localhost" port 25 - smtp

I have a little problem.
When I click send on my contact form I get the following warning:
Warning: mail() [function.mail]:
Failed to connect to mailserver at "localhost" port 25,
verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
I use 64bit Win7, but I have no idea what should I set up to make this work.

In your php.ini file you can configure which mailserver to use:
[mail function]
SMTP = mymailserver.example.com
Alternatively you can install a local mailserver as described here: http://www.php.net/manual/en/ref.mail.php#77499

Related

MySQL port 3306 not accessible remotely. port enabled on Windows server firewall

It looks like weird happening, I've followed and fixed all the possible things but still MySQL port 3306 is not accessible remotely.
Here's my setup:
Machine: Windows Server 2012 R2
MySQL Server: 8.xx
Settings have been applied:
In my.ini bind-address did to 0.0.0.0 and and thus after exec command netstat -an this is what I get TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
From Windows Firewall I've enabled port 3306 inbound/outbound both. and set that to allow edge traversal as well
From the MySQL server I've created a user with % all host and then provided permission to all databases as well. which has been checked
I guess these are the actions I took afterward. But this is not working at all.
When I'm trying to do telnet server_ip 3306 error: Connecting To server_ip ...Could not open a connection to the host, on port 3306: Connect failed from other machines. The local host is working fine.
I don't see any other workaround that could else cause this issue?
I've tried installing MySQL 8.0 on my local PC:
With default setting
Firewall turned on
No firewall exception added manually
Then I tried to connect from a remote Windows Server 2016 Standard using telnet local_ip port through command-prompt and I received this:
J
8.0.27
ZPhqTaMC v|)64Pthmmysql_native_password
Which means the connection has been established. I test it further using SQLYog tool:
and for sure I can connect to it.
What I did next was I went to my firewall setting here
Control Panel\All Control Panel Items\Windows Defender Firewall\Allowed applications
and removed all related firewall exception that was made during the installation so I've removed the following:
mysqld
port3366 <-- this is the port I used
port33060
And when I tried to connect remotely, it tells me this:
Connecting To local_ip...
Could not open connection to the host, on port 3366: Connect failed
This confirms my suspicion that firewall have blocked the connection. Now, OP said that the port have been added to the firewall but still can't connect so my first step after that is adding back mysqld into the firewall exception.
In the firewall setting click "Allow another app"
The "Add and app" dialog opens then click "Browse"
Locate mysqld from MySQL folder - usually found in C:\Program Files\MySQL\MySQL Server 8.0\bin
Click "Add" then tick both "Public" and "Private" checkbox
Once I've done that, I tried connecting and it's successful. Note that I did not re-add the ports that I've removed previously but I still can connect remotely. Also, I didn't add bind-address in my.ini setting.

Mysql-workbench not connecting to mysql in a vagrant box over ssh

I have tried all the available solutions in SO but this is still continuing. I am trying to connect Workbench to Mysql which is installed in a vagrant box. Both host and guest are Ubuntu 14.04. The attached are the screenshots.
The error now :
The logs are as below
22:08:59 [INF][ SSH tunnel]: Existing SSH tunnel not found, opening new one
22:08:59 [INF][ SSH tunnel]: Opening SSH tunnel to 127.0.0.1:2222
22:08:59 [ERR][sshtunnel.py:notify_exception_error:233]: Traceback (most recent call last):
File "/usr/share/mysql-workbench/sshtunnel.py", line 298, in _connect_ssh
look_for_keys=has_key, allow_agent=has_key)
File "/usr/lib/mysql-workbench/modules/paramiko/client.py", line 307, in connect
look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
File "/usr/lib/mysql-workbench/modules/paramiko/client.py", line 519, in _auth
raise saved_exception
AuthenticationException: Authentication failed.
22:09:00 [ERR][ SSH tunnel]: Authentication error opening SSH tunnel: Authentication error. Please check that your username and password are correct and try again.
Details (Original exception message):
Authentication failed, please check credentials.
Please refer to logs for details
This is a tricky problem, but I have some recommendations based on my experience doing the same thing. First, ssh isn't necessary when connecting to MySQL on another host as a connection is usually made via port 3306. Second, I'd give your Vagrant machine a static private IP address that you can use when connecting from the host machine. Third, I've only had success connecting as root (not sure why), but it looks like you're already doing that. And finally, MySQL by default only accepts connections from localhost which in your case is the Vagrant machine. Edit this line in /etc/my.cnf on the Vagrant machine...
bind-address = 127.0.0.1
...and change it to...
bind-address = 192.168.0.1
That's the IP of your host machine from the Vagrant machine. Alternatively you can change it to 0.0.0.0 or just comment the line to allow connections from anywhere. Make sure to restart MySQL after editing the file and try connecting again.
I was getting the same error and this was driving me nuts as well. Then I realised that I had changed my SSH server to a different port.
This must the error that MySQL workbench shows when an SSH server is denying connections.
With Vagrant I suggest you ensure you can SSH to that port from the same client or workbench won't be able to use it as a jump box.

Connect MySQL through localhost not working but 127.0.0.1 is working

OS: Ubuntu 14.04 LTS
php version control : phpbrew
php version : 5.5.10
I pinged localhost which resolved to 127.0.0.1.
This indicates that my host (/etc/hosts) file is correct.
127.0.0.1 localhost
Whenever I try connecting to MySQL using a php script like the one below it doesn't work and gives me the error: no such directory.
//connect to the database
mysql_connect("localhost","root","password") or die(mysql_error());
However, when I connect via 127.0.0.1 it will work
//connect to the database
mysql_connect("127.0.0.1","root","password") or die(mysql_error());
Additionally, my phpmyadmin does not work when logging in using "localhost" i had to change the file to add 127.0.0.1 option during log on.
How can I use localhost to connect to the MySQL database?
PHP is still trying to use the default socket location. This problem can appear if you have moved the MariaDB/MySQL folder from /var/lib/mysql to another location. In order to solve the problem you have to define the new socket's location in the /etc/php.ini file.
mysqli.default_socket =/newDBLocation/mysql/mysql.sock
Watch out, depending on which driver you use, you may have to specify the pdo_mysql.default_socket=!
In order to check your current directory run the following command in mysql:
select ##datadir;
In many cases localhost is a hint to use the UNIX socket to connect to the MySQL server process, where 127.0.0.1 forces a TCP connection. Sometimes the UNIX socket is in an unexpected place, or simply isn't accessible, which results in the "file not found" error.
The socket is typically something like /tmp/mysql.sock or could be in some other place depending on your distribution and how much you've customized it.
Keep in mind that access via UNIX socket, which is local to the server by definition, and TCP are controlled by two different rules. localhost in a GRANT refers to UNIX socket. % or some specific host name refers to remote via TCP.
The answer to this problem was that in the my.cnf located within
/etc/mysql/my.cnf
the line was either
bind-address = 127.0.0.1
or
bind-address = localhost
it should have been
bind-address = 0.0.0.0
which will allow all connections

"Host 'xxx.x.xx.xx' is not allowed to connect to this MySQL server"

In C#, windows forms, I'm trying to connect to a web server (for testing, 000webhost.com) and whatever I do it keeps saying "Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server" (where the X's are my WAN IP address).
If I do this on localhost, then it works perfectly fine, but whenever I try to connect to a database on any web server that exception gets thrown. Why does it do that and how can I fix it?
You must configure the MySQL server to allow connections from other computers than local host only.
probably there's a mysql configuration which prevents you from connecting outside localhost.
you have to bind all addresses permitted to connect to the server and comment out or delete line relative to skip-networking.
open your my.cnf configuration file (depends on machine you are on) but it should be on
/etc/mysql/my.cnf
delete bind-address line or set it to this value:
bind-address 0.0.0.0
comment out or delete it:
#skip-networking
reboot mysql server:
service mysql(d) restart
now you should be able to connect to it from any host.

Navicat Essentials (11); Can't connect to mysql server

I have just updated to Navicat Essentials 11 on Mac. I'm using Zend server and now the old settings don't work:
General tab:
Host name: localhost
Port: 3036 (tried also with 3306)
And under advanced tab:
Use socket file: /usr/local/zend/mysql/tmp/mysql.sock
I get an error:
Can't connect to local MySQL server through socket '/usr/local/zend/mysql/tmp/mysql.sock' (1)
I copied mysql.sock file to /tmp and tried with with default socket settings:
Use socket file: /tmp/mysql.sock
I also got an error
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Facts
can't connect with Navicat Essentials 11
mysql server is running
username and password are correct
socket file worked in previous version
Thank you for your help.
I'ma answering my own question:
I made a http tunnel file (Navicat -> Connection Properties -> Save Tunnel script as...) and copied in on the root of local server. Now I'm connectig via http tunnel:
http://localhost/ntunnel_mysql.php
and everything seems to work fine.
I had an error "protocol mismatch" when trying to connect at first time. Full restart of computer solved this problem too (?).