wie kann man das SSL-Zertifikat-Verifizierung Fehler

Ich verwende PHPMailer, zusammen mit Apache und PHP lokal.
Wenn ich mein test-SSL-config und meine cacerts bekomme ich

default_cert_file = C:\Program Files\Common Files\SSL/cert.pem
default_cert_file_env = SSL_CERT_FILE
default_cert_dir = C:\Program Files\Common Files\SSL/certs
default_cert_dir_env = SSL_CERT_DIR
default_private_dir = C:\Program Files\Common Files\SSL/private
default_default_cert_area = C:\Program Files\Common Files\SSL
ini_cafile = 
ini_capath = 

und dann, ich weiß

 var_dump(fsockopen("smtp.gmail.com", 465, $errno, $errstr, 3.0));
 var_dump($errno);
 var_dump($errstr);

bekommen und habe

fsockopen resource(2) of type (stream) int(0) string(0) "" 

In meinem php.ini ich habe curl.cainfo = C:/php/cacert.pem im curl Teil und es funktioniert.

Aber wenn ich versuche, mit PHPMailer senden Sie eine E-mail von localhost, ich bekomme

SSL operation failed with code 1. OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed 
Failed to enable crypto
unable to connect to ssl://smtp.gmail.com:465 (Unknown error)

Ich ging auch auf das Konto in der SMTP -, in https://accounts.google.com/DisplayUnlockCaptcha aktivieren. Und zu https://myaccount.google.com/lesssecureapps?pli=1 und aktiviert weniger gesicherten apps.
Ich denke, dies ist ein SSL Fehler und kein PHPMailer. Ehrlich gesagt, ich bin verwirrt, weiß nicht, wie es zu lösen ist. Entschuldigt meine Unwissenheit, Hilfe, auf was falsch läuft und wie man es beheben kann , wäre toll.

PS, das meine php-Datei sendet die mail. Danke

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;    
require 'C:/php/PHPMailer/src/Exception.php';
require 'C:/php/PHPMailer/src/PHPMailer.php';
require 'C:/php/PHPMailer/src/SMTP.php';

$mail = new PHPMailer(true);                             
try {

    $mail->SMTPDebug = 3;
    $mail->isSMTP();                                      
    $mail->Host = 'smtp.gmail.com'; 
    $mail->SMTPAuth = true;                               
    $mail->Username = '[email protected]';                 
    $mail->Password = 'secret';                           
    $mail->SMTPSecure = 'ssl';                            
    $mail->Port = 465;                                    

    //Recipients
    $mail->setFrom('[email protected]');
    $mail->addAddress('[email protected]');     


    //Content
    $mail->isHTML(true);                                 
    $mail->Subject = 'subject';
    $mail->Body    = 'HTML message body <b>in bold!</b>';
    $mail->AltBody = 'body in plain text';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
}            
?>

Update

Wenn ich versuche mit $mail->SMTPSecure = 'ssl'; und $mail->Port = 465; bekomme ich

2017-10-01 13:04:25 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array()
2017-10-01 13:04:26 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 [C:\php\PHPMailer\src\SMTP.php line 324]
2017-10-01 13:04:26 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [C:\php\PHPMailer\src\SMTP.php line 324]
2017-10-01 13:04:26 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [C:\php\PHPMailer\src\SMTP.php line 324]
2017-10-01 13:04:26 SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Wenn ich versuche mit $mail->SMTPSecure = 'tls'; und $mail->Port = 587; bekomme ich

2017-10-01 13:07:20 Connection: opening to smtp.gmail.com:587, timeout=300, options=array()
2017-10-01 13:07:21 Connection: opened
2017-10-01 13:07:21 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP l4sm5217189wrb.74 - gsmtp
2017-10-01 13:07:21 CLIENT -> SERVER: EHLO localhost
2017-10-01 13:07:21 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [85.75.196.114]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250 SMTPUTF8
2017-10-01 13:07:21 CLIENT -> SERVER: STARTTLS
2017-10-01 13:07:21 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2017-10-01 13:07:21 Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [C:\php\PHPMailer\src\SMTP.php line 403]
SMTP Error: Could not connect to SMTP host.
2017-10-01 13:07:21 CLIENT -> SERVER: QUIT
2017-10-01 13:07:21 SERVER -> CLIENT: 
2017-10-01 13:07:21 SMTP ERROR: QUIT command failed: 
2017-10-01 13:07:21 Connection: closed
SMTP Error: Could not connect to SMTP host.
Message could not be sent.Mailer Error: SMTP Error: Could not connect to SMTP host.
fsockopen öffnet eine TCP-Verbindung, es nicht zu tun, eine TLS-handshake, also sagen Sie nichts. Mit SMTPSecure = 'tls' und port 587 Umständen mehr feedback in der debug-Ausgabe.
Ich Tat was Sie sagte und jetzt bekomme ich Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed und dann SMTP Error: Could not connect to SMTP host.. Ich bin ein Anfänger. Was mich verwirrt ist, dass mein SSL-config und certs ok Aussehen und trotzdem bekomme ich noch Fehler. Vielleicht kann ich update meine-certs? Danke.
Zeigen, was in Ihrem debug-Ausgabe, nicht nur die Letzte Fehlermeldung.
Überprüfen Sie das update in Frage.
OK, das zeigt zumindest sind Sie nicht umgeleitet woanders. Ich schlage vor, mit openssl (wie beschrieben in der Anleitung zur Störungsbeseitigung), um zu überprüfen, dass Ihre CA-Zertifikate Datei arbeiten - Google wird nicht für die Veröffentlichung einer ungültigen cert.

InformationsquelleAutor slevin | 2017-10-01

Schreibe einen Kommentar