I have a problem connecting to SMTP-Server via PHPMailer.
<?php
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = true;
$mail->Host = "ip.ip.ip.ip";
$mail->Port = "25";
$mail->Helo = "";
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = "";
$mail->SMTPAuth = false;
$mail->Timeout = 10;
$mail->From = "sender@example.com";
$mail->FromName = "Sender Name";
$mail->addAddress("receiver@example.com");
$mail->isHTML(true);
$mail->Subject = "Test";
$mail->Body = "<h1>Test</h1>";
if(!$mail->Send()) {
echo $mail->ErrorInfo;
} else {
echo "Mail sent...";
}
I figured out the main problem: After successfully connect the server is NOT sending a "220 announcement" directly. It is sending nothing but waiting for a EHLO. After any client input the server sends a "220 announcement"! I tested it with telnet.
I newer saw it before and i don't know if it respects the rfc.
The 220 AFTER the EHLO makes PHPMailer completely crashing. Any following communication is "misunderstood". I saw that PHPMailer is waiting for a 220 announcement after connecting. But this fails because the server is not sending anything. When the timeout is reached the client sends a EHLO. After that it receives a 220 but the following communication fails.
Here is the full communication output:
2017-03-30 13:38:48 Connection: opening to ip.ip.ip.ip:587, timeout=10, options=array (
)
2017-03-30 13:38:48 Connection: opened
2017-03-30 13:38:58 SMTP -> get_lines(): $data is ""
2017-03-30 13:38:58 SMTP -> get_lines(): $str is ""
2017-03-30 13:38:58 SMTP -> get_lines(): timed-out (10 sec)
2017-03-30 13:38:58 SERVER -> CLIENT:
2017-03-30 13:38:58 CLIENT -> SERVER: EHLO conweb1.example.de
2017-03-30 13:38:58 SMTP -> get_lines(): $data is ""
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "220 EX-02.example.loc Microsoft ESMTP MAIL Service ready at Thu, 30 Mar 2017 15:38:58 +0200
"
2017-03-30 13:38:58 SERVER -> CLIENT: 220 EX-02.example.loc Microsoft ESMTP MAIL Service ready at Thu, 30 Mar 2017 15:38:58 +0200
2017-03-30 13:38:58 SMTP ERROR: EHLO command failed: 220 EX-02.example.loc Microsoft ESMTP MAIL Service ready at Thu, 30 Mar 2017 15:38:58 +0200
2017-03-30 13:38:58 CLIENT -> SERVER: HELO conweb1.example.de
2017-03-30 13:38:58 SMTP -> get_lines(): $data is ""
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-SIZE 36700160
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-PIPELINING
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-DSN
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
250-DSN
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-STARTTLS
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-AUTH LOGIN
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH LOGIN
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-8BITMIME
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH LOGIN
250-8BITMIME
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250-BINARYMIME
"
2017-03-30 13:38:58 SMTP -> get_lines(): $data is "250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH LOGIN
250-8BITMIME
250-BINARYMIME
"
2017-03-30 13:38:58 SMTP -> get_lines(): $str is "250 CHUNKING
"
2017-03-30 13:38:58 SERVER -> CLIENT: 250-EX-02.example.loc Hello [ip.ip.ip.ip]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH LOGIN
250-8BITMIME
250-BINARYMIME
250 CHUNKING
2017-03-30 13:38:58 CLIENT -> SERVER: MAIL FROM:<personal@example.com>
2017-03-30 13:39:03 SMTP -> get_lines(): $data is ""
2017-03-30 13:39:03 SMTP -> get_lines(): $str is "250 EX-02.example.loc Hello [ip.ip.ip.ip]
"
2017-03-30 13:39:03 SERVER -> CLIENT: 250 EX-02.example.loc Hello [ip.ip.ip.ip]
2017-03-30 13:39:03 CLIENT -> SERVER: RCPT TO:<tm@example.com>
2017-03-30 13:39:03 SMTP -> get_lines(): $data is ""
2017-03-30 13:39:03 SMTP -> get_lines(): $str is "250 2.1.0 Sender OK
"
2017-03-30 13:39:03 SERVER -> CLIENT: 250 2.1.0 Sender OK
2017-03-30 13:39:03 CLIENT -> SERVER: DATA
2017-03-30 13:39:03 SMTP -> get_lines(): $data is ""
2017-03-30 13:39:03 SMTP -> get_lines(): $str is "250 2.1.5 Recipient OK
"
2017-03-30 13:39:03 SERVER -> CLIENT: 250 2.1.5 Recipient OK
2017-03-30 13:39:03 SMTP ERROR: DATA command failed: 250 2.1.5 Recipient OK
2017-03-30 13:39:03 SMTP Error: data not accepted.
SMTP Error: data not accepted.SMTP server error: DATA command failed Detail: Recipient OK
SMTP code: 250 Additional SMTP info: 2.1.52017-03-30 13:39:03 CLIENT -> SERVER: QUIT
2017-03-30 13:39:03 SMTP -> get_lines(): $data is ""
2017-03-30 13:39:03 SMTP -> get_lines(): $str is "354 Start mail input; end with <CRLF>.<CRLF>
2017-03-30 13:39:03 SMTP ERROR: QUIT command failed: 354 Start mail input; end with <CRLF>.<CRLF>
2017-03-30 13:39:03 Connection: closed
The main question is: Is the error caused by a wrong protocol implementation of PHP-Mailer? Or is the SMTP Server misconfigured?