SMTP host. Failed to connect to server

hello im getting this error when im try to send any email

SMTP Error: Could not connect to SMTP host. Failed to connect to server

im running a wordpress website please help me to fix it.

How do you try to send the mail?

Well, the error is obvious, there is no connection to the host and port you are using for smtp. If you give more details of how you are configuring the smtp data, which client, plugin, etc. are you using, more chances to get help.

1 Like

im using fluent-mail wordpress plugin.

here is a screen short.

im try these port 1 by 1 still not working.

SSL/TLS Port 465
STARTTLS Port 587


No encryption Port 25

Your mail host is resolving correctly?

From your Hestia server:

telnet mail.yourdomain 465

If you share the domain I can check it from my side.

Per your screenshot, STARTTLS is recommended for port 25.

You omitted the SMTP server hostname from your shared details and it is not visible in your screenshot. You also don’t mention if it is the same host as the HestiaCP host running the WordPress site. Both of hose details are relevant to troubleshoot your configuration.

Also helpful would be knowing if the settings that you are using work anywhere else, such as in a standard email client.

1 Like

telnet: could not resolve mail.gplcoder.com/465: Name or service not known

its same host. hestiacp and wordpress site same hosting

its contabo hosting.

mail.gplcoder.com doesn’t have an A record, you should add your public ip to the record.

1 Like

You need to set that mail hostname to DNS Only in your Cloudflare. The Cloudflare proxy only passes HTTP and HTTPS traffic without a Spectrum plan. It will not permit SMTP traffic.

1 Like

please can u check setting and tell me where i did wrong ?

here is screen short

@linkp already gave the solution:

1 Like

1 Like

As I already indicated, you need to:

Click Edit on that top entry and switch the mail hostname from Proxied to DNS Only.

i have change proxied to DNS only but…

no success im try with an other plugin WP Mail SMTP

same error.

Versions:
WordPress: 6.6.2
WordPress MS: No
PHP: 8.2.15
WP Mail SMTP: 4.1.1

Params:
Mailer: smtp
Constants: No
ErrorInfo: SMTP Error: Could not connect to SMTP host. Failed to connect to serverSMTP server error: Failed to connect to server
Host: mail.gplcoder.com
Port: 465
SMTPSecure:

ssl

SMTPAutoTLS:

bool(true)

SMTPAuth:

bool(true)

Server:
OpenSSL: OpenSSL 1.1.1f 31 Mar 2020

Debug:
Email Source: WP Mail SMTP Mailer: Other SMTP SMTP Error: Could not connect to SMTP host. Failed to connect to serverSMTP server error: Failed to connect to server

SMTP Debug:

2024-10-04 17:58:09 Connection: opening to ssl://mail.gplcoder.com:465, timeout=30, options=array()
2024-10-04 17:58:09 Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [/home/admin2/web/gplcoder.com/public_html/wp-includes/PHPMailer/SMTP.php line 408]
2024-10-04 17:58:09 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [/home/admin2/web/gplcoder.com/public_html/wp-includes/PHPMailer/SMTP.php line 408]
2024-10-04 17:58:09 Connection failed. Error #2: stream_socket_client(): Unable to connect to ssl://mail.gplcoder.com:465 (Unknown error) [/home/admin2/web/gplcoder.com/public_html/wp-includes/PHPMailer/SMTP.php line 408]
2024-10-04 17:58:09 SMTP ERROR: Failed to connect to server: (0)
SMTP Error: Could not connect to SMTP host. Failed to connect to server

The certificate you are using is not valid for your domain.

Options:

1.- I recommended this option.

Create also a subdomain webmail on Cloudflare like the one you created for mail. Once done, in Hestia, edit the mail domain gplcoder.com enable SSL and issue a Let’s Encrypt certificate.
imagen

Once done you should have no issues to connect to mail.gplcoder.com on ports 465 (SSL) or 587 (STARTTLS).

2.- This could or couldn’t work but you can try to use localhost as host and port 25, no ssl and no starttls.

3.- I don’t know if the plugin also checks the chain of trust on the certificate but you could use ports 465 or 587 but using as host your server hostname vmi232443.contaboserver.net

1 Like

im try this to not working. even im try vmi20… by main server host. not working.

ErrorInfo: SMTP Error: Could not connect to SMTP host. Failed to connect to serverSMTP server error: Failed to connect to server Additional SMTP info: php_network_getaddresses: getaddrinfo for mail.gplcoder.com failed: Temporary failure in name resolution

=====================

one thing im forget to tell .im using really-simple-security wordpress plugin. ?

You are having two issues, once you connect but the certificate is not valid and now it doesn’t resolve the host, that’s pretty strange.

Did you try to issue a certificate? Because webmail subdomain is proxied and that won’t work.

I know nothing about that plugin so no idea whether it causes any issues but you can always disable it and test again.

after active ssl in hestiacp

now im getting this error.

Ok, I confirm your server is using the new certificate:

$ ssl_check mail.gplcoder.com 465
2024-10-05 06:59 - Checking mail.gplcoder.com on port 465

issuer=C = US, O = Let's Encrypt, CN = R11
subject=CN = mail.gplcoder.com
notBefore=Oct  5 03:50:34 2024 GMT
notAfter=Jan  3 03:50:33 2025 GMT
SANs: mail.gplcoder.com,webmail.gplcoder.com

So the problem is that the plugin can’t resolve the domain. Do your server has a public ip directly added to your net interface or is it nated?

Show the output of these commands:

ip a
getent ahosts mail.gplcoder.com
dig mail.gplcoder.com +short

ok i have send u screen short in private. please check