SMTP connect () failed

1

Thanks for your kind help:)

At the moment I am trying to send an email using PHPMailer to which I get the following error:

SERVER -> CLIENT: 220 smtp.gmail.com ESMTP t129sm8288876vkc.0 - gsmtp
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [186.155.13.179]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS

**Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\xampp\htdocs\BiciBogota\phpmailer\class.smtp.php on line 269
CLIENT -> SERVER: QUIT**


SMTP connect() failed.
Ha ocurrido un error, el mensaje no ha sido enviado: SMTP connect() failed.

The code is as follows:

date_default_timezone_set('Etc/UTC');
require 'PHPMailer/PHPMailerAutoload.php';

require ('conexion.php');

$mail = new PHPMailer;

$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';

$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->SMTPAuth = true;

$mail->CharSet = 'UTF-8';

$mail->Username = "[email protected]";
$mail->Password = "bicibogotacontrasena";
$mail->setFrom('[email protected]', 'contrasena787');
$mail->addAddress($correo_recibe, 'Marcela Gomez');
$mail->Subject = '¡Alguien encontró tu bici!';
$mail->msgHTML("<!DOCTYPE html>
                <html lang='en'>
                <head>
                    <meta charset='UTF-8'>
                    <title>Título</title>
                </head>
                <body>
                    Hola! ".$nombre.", desde BiciBogotá queremos informarte que al parecer alguien ha encontrado tu bici. Éstos fueron los datos que nos proporcionó: <br>

                    Datos de la bici

                    Serial: ".$serial."<br>
                    Marca: ".$marca."<br>

                    Dónde lo encontró?

                    Localidad: ".$localidad."<br>
                    Barrio: ".$barrio."<br>
                    Direccion: ".$direccion."<br><br>


                    Mensaje adicional: ".$mensaje."<br>

                    Si este mensaje ha sido de utilidad y has recuperado tu bicicleta reportalo &nbsp <button><a href=".$link.">&nbsp¡AQUÍ!&nbsp</a></button>&nbsp (o copia y pega este link: ".$link."), de esta manera ya no aparecerá más en la sección de bicicletas perdidas de tu perfil y no tendrás problemas con lo retenes de la ciudad.

                </body>
                </html>");

if (!$mail->send()) {
    echo "Ha ocurrido un error, el mensaje no ha sido enviado: " . $mail->ErrorInfo;
} else {
    echo "Mensaje enviado!";

I receive the variables by post and a query in the database Several errors of this type have been published, however, the solutions given did not work for me. Among others, I removed the one; to the line extension = php_openssl.dll from php.ini, I changed the port to 465, I changed the sending mail which has the permission to access less secure applications activated ...

So if anyone has another solution, I'm attentive. : D

    
asked by DianaDiana 05.10.2017 в 04:46
source

1 answer

2

The problem is that PHP introduces the verification of the SSL certificate and in the mail server you are using a non-certified server, therefore, you have to deactivate the verification, just before sending ($ mail-> send () ).

$mail->smtpConnect([
   'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    ]
]);
    
answered by 24.04.2018 в 23:19