New in CWP Edge-LatestFree with every CWPpro licenceWebsites up to 300x faster

CWP now includes LSPHP, LSAPI-Cache and CWP Cage at no extra cost with all CWPpro licences. The LSAPI-Cache plugin is integrated into our WordPress and other script installers, and CWP Cage gives every user complete isolation. Available now in the CWP Edge-Latest version.

Get CWPpro ›

SMTP Error: Could not connect to SMTP host.

Started by LesiuNOL, November 07, 2023, 10:25:22 AM

Previous topic - Next topic

LesiuNOL

Hello,
I have a problem connecting to SMTP with PhpMailer. It's throwing me this error:

SMTP Error: Could not connect to SMTP host. Connection failed. stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

Link to script: https://yaperfumy.pl/mail.php


<?php
use PHPMailer\PHPMailer\PHPMailer;
use 
PHPMailer\PHPMailer\SMTP;
use 
PHPMailer\PHPMailer\Exception;

require_once 
__DIR__ . '/vendor/phpmailer/phpmailer/src/Exception.php';
require_once 
__DIR__ . '/vendor/phpmailer/phpmailer/src/PHPMailer.php';
require_once 
__DIR__ . '/vendor/phpmailer/phpmailer/src/SMTP.php';

$mail = new PHPMailer(true);
$mail->SMTPDebug = 1;
$mail->isSMTP();
$mail->Host = 'mail.yaperfumy.pl';
$mail->SMTPAuth = true;
$mail->Username = "test@yaperfumy.pl";
$mail->Password = "password";
$mail->SMTPSecure = "tls";
$mail->Port = 587;

$mail->From = "test@yaperfumy.pl";
$mail->FromName = "Full Name";

$mail->addAddress("lesniewski.jakub94@gmail.com", "recipient name");

$mail->isHTML(true);

$mail->Subject = "Mail sent from php send mail script.";
$mail->Body = "<i>Text content from send mail.</i>";
$mail->AltBody = "This is the plain text version of the email content";

try {
    
$mail->send();
    echo 
"Message has been sent successfully";
} catch (
Exception $e) {
    echo 
"Mailer Error: " . $mail->ErrorInfo;
}
?>


Starburst

Allot of providers have PHP Mail disabled for security.
(block the users to be able to send spam emails or infected emails from php mail function.)

If you have root access, then you can enable it.

You might have to contact your upstream also to make sure all the SMTP ports are open.