Hi,I am using php mailer in my php script running in lamp app, connecting to the smtp server in a mail app on the same NS8 node, sending mails just to NS8 users. It was working perfectly for months till the last lamp and mail apps update. Now it throws an error:
Mailer Error:SMTP Error: Could not connect to SMTP host. Failed to connect to server SMTP server error: Failed to connect to server SMTP code: 111 Additional SMTP info: Connection refused
PHP mailer ver. 6.12.0
SMTP access from clients in LAN works without problem (on TLS/587)
I have also tried to switch php mailer to relay on port 25 without authentication (with appropriate relay settings in the maill app), but without success.
I guess the nodes FQDN is the same as the mail server hostname.
Setting the nodes FQDN sets an entry in the hosts /etc/hosts:
127.0.1.1 node.domain.tld node
The hosts /etc/hosts is also used in the containers like the apache2-app container of the lamp app. So when the PHPMailer script is executed in the lamp container and it wants to connect to the mail server at node.domain.tld it doesn’t reach it as it connects to 127.0.1.1 which is the lamp container itself and not the mail server.
So I changed the nodes FQDN at the nodes page to another name which adapts the /etc/hosts entry, see Cluster management — NS8 documentation
Be careful to set a name that points to the server to reach it again. In case something went wrong, it should always be possible to reach the cluster admin using the IP.
If you obtained a certificate for the node don’t forget to get a new one.
Then I restarted lamp to use the corrected /etc/hosts:
Hi,
I am developing another web application, this time on the NS8 Webserver app, and I am getting the same problem, as was resolved with the LAMP app earlier.
SMTP Error: Could not connect to SMTP host. Failed to connect to server SMTP server error: Failed to connect to server SMTP code: 111 Additional SMTP info: Connection refused
The PHP Mailer settings within the Webserver app are practically the same
Is hur.twr.cz the mail server hostname which is also the nodes FQDN?
Because of the entry in /etc/hosts, it resolves to 127.0.1.1 which doesn’t work inside the container.
To check the SSL connection from inside the php container: (adapt php7.4 to the php version you’re using)
Is hur.twr.cz the mail server hostname which is also the nodes FQDN?
Yes it is
[root@hur admin]# /usr/local/bin/runagent -m webserver1 podman exec php7.4-fpm openssl s_client -connect hur.twr.cz:587 -starttls smtp Error: crun: executable file openssl not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found