Control Web Panel

WebPanel => SSL => Topic started by: LesiuNOL on November 07, 2023, 10:25:22 AM

Title: SMTP Error: Could not connect to SMTP host.
Post by: LesiuNOL on November 07, 2023, 10:25:22 AM
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


Code: [Select]
<?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;
}
?>
Title: Re: SMTP Error: Could not connect to SMTP host.
Post by: KernelStackDump on December 12, 2023, 11:10:41 PM
Contact your hosting privider
(https://www.blackhatworld.com/attachments/1669196815632-png.233346/)
Title: Re: SMTP Error: Could not connect to SMTP host.
Post by: Starburst on December 12, 2023, 11:39:09 PM
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.