PHPMailer konnte keine Verbindung zum SMTP-Host herstellen

In den letzten 2 Tagen habe ich versucht, ein PHP-Skript zum Senden einer E-Mail zu veranlassen, und es scheint nicht zu funktionieren. Zuerst habe ich die normale PHP-Mail-Funktion ausprobiert, dann PHPMailer und dann Swiftmailer.

Ich habe versucht, die Google Mail-Konten und SMTP sowie das E-Mail-Konto und SMTP meines Internet-Providers zu verwenden. Ich habe versucht, beide SMTP-Server zu pingen, und sie funktionierten einwandfrei und Telnet antwortete auch richtig. Auf telnet smtp.gmail.com 587 hieß es 220 smtp.gmail.com ESMTP q125sm9630397wmd.19 - gsmtp. Ich habe Port 465 und 587 und Kombinationen mit tls und ssl ausprobiert. Für Google Mail habe ich auch mein Google Mail-Konto bearbeitet, um sicherzustellen, dass es für weniger sichere Geräte zulässig ist und um IMAP usw. zuzulassen.

Ich führe Apache auf meinem eigenen PC unter Windows 7 aus. Ich habe die Ports 465 und 587 weitergeleitet. Ich habe bereits die Seite zur Fehlerbehebung von PHPMailer durchgearbeitet. Ich habe auch die Firewall zum Testen deaktiviert, aber das hat nicht geholfen.

Ich habe die php.ini-Einstellungen korrekt bearbeitet und auch sichergestellt, dass die; wurde von extension = php_openssl.dll entfernt.

Dies ist mein Code für PHPMailer, basierend auf dem für Google Mail bereitgestellten PHPMailer-Beispiel (ich habe SMTP, Konten und Kennwörter bearbeitet):

require '/PHPMailer/PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.x.x';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = '[email protected]';                 // SMTP username
$mail->Password = 'password';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]');     // Add a recipient

$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
$checkup = 'Something went wrong';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
$checkup = 'Success';
}

Wenn ich das auf dem SMTP meines Internetproviders mit meiner Internetprovider-E-Mail-Adresse verwende, erhalte ich diesen Fehler:

2016-05-06 12:27:04 Connection: opening to smtp.x.x:587, timeout=300, options=array ( ) 2016-05-06 12:27:04 
Connection: opened 2016-05-06 12:27:04  
SERVER -> CLIENT: 220-smtp6.mnd.mail.iss.as9143.net ESMTP Fri, 06 May 2016 14:27:07 +0200 220-Sending spam or unsolicited commercial e-mail to this server is strictly 220-prohibited by our NO UBE / NO UCE policy. Abuse will be prosecuted and/or 220 charged per attempted recipient at international postal rates. 2016-05-06 12:27:04 
CLIENT -> SERVER: EHLO localhost 2016-05-06 12:27:04    
SERVER -> CLIENT: 250-smtp6.mnd.mail.iss.as9143.net Hello (MY IP ADDRESS, edited out for security) 250-SIZE 31457280 250-8BITMIME 250-PIPELINING 250-STARTTLS 250 HELP 2016-05-06 12:27:04
CLIENT -> SERVER: STARTTLS 2016-05-06 12:27:04  SERVER -> CLIENT: 220 TLS go ahead 2016-05-06 12:27:04  SMTP Error: Could not connect to SMTP host. 2016-05-06 12:27:04 CLIENT -> SERVER: QUIT 2016-05-06 12:27:04  
SERVER -> CLIENT: MIA�x�����dqi7��=���&J��3ʚ���ă�S�_��Z�$��NH�؏�|��m>[z@�f�g��G����.pAGD�8Q�:��J���'L�a8%��v�(*YC��u�ФW�s����l�#6F�w���� ���9�|�\%�!�����B=:��/U��m��bc\�cڊ��4��d�-U��seEZ�PC��Q�Ai`JㅇK�U�]h���H�v���i���cF M΂�x ���}���V�HR�c�!��,`�   *)�$Oȕ�EMƍ�&B�+���u9A�R��j'[7��y����a ����N���� 2016-05-06 12:27:04    
SMTP ERROR: QUIT command failed: MIA�x�����dqi7��=���&J��3ʚ���ă�S�_��Z�$��NH�؏�|��m>[z@�f�g��G����.pAGD�8Q�:��J���'L�a8%��v�(*YC��u�ФW�s����l�#6F�w���� ���9�|�\%�!�����B=:��/U��m��bc\�cڊ��4��d�-U��seEZ�PC��Q�Ai`JㅇK�U�]h���H�v���i���cF  M΂�x ���}���V�HR�c�!��,`�   *)�$Oȕ�EMƍ�&B�+���u9A�R��j'[7��y����a ����N���� 2016-05-06 12:27:04    
Connection: closed 2016-05-06 12:27:04  
SMTP connect() failed. Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Wie Sie sehen, stellt der SMTP-Server eine Verbindung her, erkennt mich an der IP-Adresse und meldet "Weiter". Dann schlägt er plötzlich fehl. Ich habe überall gesucht und bin völlig ratlos, wie ich das beheben kann.

Wenn ich Google Mail über SMTP verwende, wird auf dem Google Mail-Konto Folgendes angegeben:

2016-05-06 17:42:40 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ) 2016-05-06 17:42:40   
Connection: opened 2016-05-06 17:42:40  
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 8sm9564071wms.14 - gsmtp 2016-05-06 17:42:40 CLIENT -> SERVER: EHLO localhost 2016-05-06 17:42:40    
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [MY IP ADDRESS] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250 SMTPUTF8 2016-05-06 17:42:40   
CLIENT -> SERVER: STARTTLS 2016-05-06 17:42:40  
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2016-05-06 17:42:40  SMTP Error: Could not connect to SMTP host. 2016-05-06 17:42:40
CLIENT -> SERVER: QUIT 2016-05-06 17:42:40  
SERVER -> CLIENT: MIA��b8   ��4}�5KO�q0
2016-05-06 17:42:40 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ) 2016-05-06 17:42:40   
Connection: opened 2016-05-06 17:42:40  
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 8sm9564071wms.14 - gsmtp 2016-05-06 17:42:40 CLIENT -> SERVER: EHLO localhost 2016-05-06 17:42:40    
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [MY IP ADDRESS] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250 SMTPUTF8 2016-05-06 17:42:40   
CLIENT -> SERVER: STARTTLS 2016-05-06 17:42:40  
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2016-05-06 17:42:40  SMTP Error: Could not connect to SMTP host. 2016-05-06 17:42:40
CLIENT -> SERVER: QUIT 2016-05-06 17:42:40  
SERVER -> CLIENT: MIA��b8   ��4}�5KO�q0$&��B.r��Q���P��=���r$�%➽,��X�"�c�5ȭ�D�C�b���B��@��T�?bڌ_�*܋����X1`T%_��� �QQ����y}]OO�����8d�R|�$�����b�����[� ,��5�[*�H����5�l���B����a����f��f���Pj��c@>����vk+Cq�r*��-�4���`W勱A``A�S ,�w:�q�1�����.����*�',ȁ��iH�T0�E�/1W��  |�i4�{�Gk�J�n,US�F�|���|L����n}Qp� 2016-05-06 17:42:40  
SMTP ERROR: QUIT command failed: MIA��b8    ��4}�5KO�q0$&��B.r��Q���P��=���r$�%➽,��X�"�c�5ȭ�D�C�b���B��@��T�?bڌ_�*܋����X1`T%_��� �QQ����y}]OO�����8d�R|�$�����b�����[� ,��5�[*�H����5�l���B����a����f��f���Pj��c@>����vk+Cq�r*��-�4���`W勱A``A�S ,�w:�q�1�����.����*�',ȁ��iH�T0�E�/1W��  |�i4�{�Gk�J�n,US�F�|���|L����n}Qp� 2016-05-06 17:42:40  
Connection: closed 2016-05-06 17:42:40  SMTP connect() failed.  Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
amp;��B.r��Q���P��=���r$�%➽,��X�"�c�5ȭ�D�C�b���B��@��T�?bڌ_�*܋����X1`T%_��� �QQ����y}]OO�����8d�R|�$�����b�����[� ,��5�[*�H����5�l���B����a����f��f���Pj��c@>����vk+Cq�r*��-�4���`W勱A``A�S ,�w:�q�1�����.����*�',ȁ��iH�T0�E�/1W�� |�i4�{�Gk�J�n,US�F�|���|L����n}Qp� 2016-05-06 17:42:40 SMTP ERROR: QUIT command failed: MIA��b8 ��4}�5KO�q0
2016-05-06 17:42:40 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ) 2016-05-06 17:42:40   
Connection: opened 2016-05-06 17:42:40  
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 8sm9564071wms.14 - gsmtp 2016-05-06 17:42:40 CLIENT -> SERVER: EHLO localhost 2016-05-06 17:42:40    
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [MY IP ADDRESS] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250 SMTPUTF8 2016-05-06 17:42:40   
CLIENT -> SERVER: STARTTLS 2016-05-06 17:42:40  
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS 2016-05-06 17:42:40  SMTP Error: Could not connect to SMTP host. 2016-05-06 17:42:40
CLIENT -> SERVER: QUIT 2016-05-06 17:42:40  
SERVER -> CLIENT: MIA��b8   ��4}�5KO�q0$&��B.r��Q���P��=���r$�%➽,��X�"�c�5ȭ�D�C�b���B��@��T�?bڌ_�*܋����X1`T%_��� �QQ����y}]OO�����8d�R|�$�����b�����[� ,��5�[*�H����5�l���B����a����f��f���Pj��c@>����vk+Cq�r*��-�4���`W勱A``A�S ,�w:�q�1�����.����*�',ȁ��iH�T0�E�/1W��  |�i4�{�Gk�J�n,US�F�|���|L����n}Qp� 2016-05-06 17:42:40  
SMTP ERROR: QUIT command failed: MIA��b8    ��4}�5KO�q0$&��B.r��Q���P��=���r$�%➽,��X�"�c�5ȭ�D�C�b���B��@��T�?bڌ_�*܋����X1`T%_��� �QQ����y}]OO�����8d�R|�$�����b�����[� ,��5�[*�H����5�l���B����a����f��f���Pj��c@>����vk+Cq�r*��-�4���`W勱A``A�S ,�w:�q�1�����.����*�',ȁ��iH�T0�E�/1W��  |�i4�{�Gk�J�n,US�F�|���|L����n}Qp� 2016-05-06 17:42:40  
Connection: closed 2016-05-06 17:42:40  SMTP connect() failed.  Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
amp;��B.r��Q���P��=���r$�%➽,��X�"�c�5ȭ�D�C�b���B��@��T�?bڌ_�*܋����X1`T%_��� �QQ����y}]OO�����8d�R|�$�����b�����[� ,��5�[*�H����5�l���B����a����f��f���Pj��c@>����vk+Cq�r*��-�4���`W勱A``A�S ,�w:�q�1�����.����*�',ȁ��iH�T0�E�/1W�� |�i4�{�Gk�J�n,US�F�|���|L����n}Qp� 2016-05-06 17:42:40 Connection: closed 2016-05-06 17:42:40 SMTP connect() failed. Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

m Debug-Modus 4 heißt es dasselbe (dies zeigt nur einen Teil der riesigen Textwand, die Sie dann erhalten):

CLIENT -> SERVER: STARTTLS 2016-05-06 17:55:10 
SMTP -> get_lines(): $data is "" 2016-05-06 17:55:10    
SMTP -> get_lines(): $str is "220 TLS go ahead " 2016-05-06 17:55:10    
SERVER -> CLIENT: 220 TLS go ahead 2016-05-06 17:55:10  SMTP Error: Could not connect to SMTP host. 2016-05-06 17:55:10 
CLIENT -> SERVER: QUIT 2016-05-06 17:55:10  
SMTP -> get_lines(): $data is "" 2016-05-06 17:55:10    
SMTP -> get_lines(): $str is "MIA " 2016-05-06 17:55:10 
SMTP -> get_lines(): $data is "MIA " 2016-05-06 17:55:10

Es wird Bereit zum Starten von TLS angezeigt und anschließend wird angezeigt, dass die Verbindung erneut fehlgeschlagen ist. Ich habe viele Themen über Stackoverflow gelesen, aber bisher hat keine der dort angebotenen Lösungen und Optionen funktioniert. Hat jemand eine Idee?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage