Articles in this section

Unable to send an email via PHP mail form: Failed to connect to server: (0)SMTP connect() failed

Plesk for Windows kb: technical ABT: Group B

Applicable to:

  • Plesk for Windows

Symptoms

When submitting a form on a website that uses PHPMailer or sending a test email via WP Mail SMTP, the operation fails with:

CONFIG_TEXT: Warning: stream_socket_enable_crypto(): Peer certificate CN=`server.hostname.com' did not match expected CN=`localhost' in C:\Inetpub\vhosts\example.com\httpdocs\wp-includes\class-smtp.php on line 369
...
SMTP ERROR: Failed to connect to server: (0)SMTP connect() failed

Cause

Incorrect SMTP Host is specified in configuration.

Resolution

Use the domain name or the server hostname in mail configuration.

Note: Domain / hostname must be secured with an SSL certificate.

Note: Hostname can be found on the Home page in Plesk or in MailEnable Management Console > Services > localhost > Services  and Connectors > SMTP Properties > General > Local domain name.

 

Examples:

PHPMailer

CONFIG_TEXT: $mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'example.com'; // Specify main and backup server
$mail->Port = 25; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'john_doe@example.com'; // SMTP username
$mail->Password = '******'; // SMTP password
$mail->SMTPSecure = 'tls';

 

WP Mail SMTP plugin for WordPress (WordPress AdminSettings > Email > SMTP Host):


3.jpg

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.