PHPMailer sent a message but returned the CLIENT / SERVER dialog to the browser

So, I searched Google and Stackoverflow, and I am a little surprised that I could not find this problem.

I use XAMPP / localhost and PHPmailer, sending an email to my yahoo account using my gmail email account. Everything worked fine with sending and receiving email, including an example application.

The problem is that in my browser the SERVER / CLIENT dialog box is displayed for each stage of the scene processing immediately before the message "Sent successfully".

Sample output here:

2014-02-04 05:44:36 SERVER -> CLIENT: 220 mx.google.com ESMTP xv2sm62192389pbb.39 - gsmtp 2014-02-04 05:44:36 CLIENT -> SERVER: EHLO localhost 2014-02-04 05:44:36 SERVER -> CLIENT: 250-mx.google.com at your service, [171.6.91.113] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN 250-ENHANCEDSTATUSCODES 250 CHUNKING 2014-02-04 05:44:36 CLIENT -> SERVER: AUTH LOGIN 2014-02-04 05:44:36 SERVER -> CLIENT: 334 VXNlcm5hbWU6 2014-02-04 05:44:36 CLIENT -> SERVER: a2hyZng0NDRAZ21haWwuY29t 2014-02-04 05:44:37 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 2014-02-04 05:44:37 CLIENT -> SERVER: RnV0dXJlMTA= 2014-02-04 05:44:38 SERVER -> CLIENT: 235 2.7.0 Accepted . . 25 more lines of this stuff . 2014-02-04 05:44:40 CLIENT -> SERVER: QUIT 2014-02-04 05:44:40 SERVER -> CLIENT: 221 2.0.0 closing connection xv2sm62192389pbb.39 - gsmtp Message has been sent 

I put line breaks to make it more readable, but it displays as one long line on the screen.

Here is the code. How can I suppress this conclusion?

 require_once "../phpmailer/class.phpmailer.php"; $mail = new \PHPMailer(true); $mail->IsSMTP(); $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->SMTPDebug = 2; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Username = " xxx@gmail.com "; $mail->Password = "xxx"; $mail->SetFrom(' xxx@gmail.com ', 'Randy S'); $mail->WordWrap = 50; $mail->AddAddress(' xxx@yahoo.com ', 'Randy'); $mail->Subject = 'PHPMailer Test Subject'; $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; $mail->AddAttachment('upload/names.txt'); // attachment if(!$mail->Send()){ echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } 
+7
php email phpmailer localhost
source share
3 answers

Comment or delete this line or set it to 0 :

 $mail->SMTPDebug = 2; 

Used to display errors and messages.

From the PHPMailer website:

$ mail-> SMTPDebug = 2; // enables SMTP debugging information (for testing)
// 1 = errors and messages
// 2 = messages only

+16
source share

SMTPDebug defined in class.phpmailer.php as shown below. Accordingly, you must initialize SMTPDebug as 0. Thus, no command or data messages will be displayed. In addition, you can view the error message when an error occurs using the ErrorInfo field of the PHPMailer class.

 /** * SMTP class debug output mode. * Debug output level. * Options: * * `0` No output * * `1` Commands * * `2` Data and commands * * `3` As 2 plus connection status * * `4` Low-level data output * @type integer * @see SMTP::$do_debug */ public $SMTPDebug = 0; 
+1
source share

I faced the same problem add

 $mail->SMTPDebug = false; 

in the post script, after

 $mail->WordWrap = 50; 

He will work

0
source share

All Articles