Search code examples
phpemailphpmailer

sending email using phpmailer returns a chunk of data


I a trying to send email using phpmailer but after sending email i get a chunk of data even the mail is successfully delivered can anyone please help me to know that why is this happening and how can i stop seeing this message

this what i have done for sending mail

$mail = new PHPMailer;

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

$mail->isSMTP();   
$mail->SMTPDebug = 1;                                    // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com';                         // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                                // Enable SMTP authentication
$mail->Username = 'myemail@gmail.com';         // SMTP username
$mail->Password = 'myphonenumber';                      // SMTP password
$mail->SMTPSecure = 'tls';                          // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;  
$mail->SetFrom('example@testrun.com','yahoo');
$mail->addAddress('example@test.com', 'User'); // Add a recipient
$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()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

what i am getting after sending email is

2017-02-14 16:34:18 CLIENT -> SERVER: EHLO localhost
2017-02-14 16:34:19 CLIENT -> SERVER: STARTTLS 2017-02-14 16:34:19  
CLIENT -     > SERVER: EHLO localhost 2017-02-14 16:34:19   
CLIENT -> SERVER: AUTH LOGIN 
2017-02-14 16:34:20 CLIENT -> SERVER: c2hhaGlka2hhbjAyMTFAZ21haWwuY29t 2017-    02-14 16:34:20
CLIENT -> SERVER: NzczNjEyNzQ5OA== 2017-02-14 16:34:21  CLIENT -> SERVER: MAIL FROM: 2017-02-14 16:34:21 
CLIENT -> SERVER: RCPT TO: 2017-02-14 16:34:21  CLIENT -> SERVER: DATA 2017-02-14 16:34:22  
CLIENT -> SERVER: Date: Tue, 14 Feb 2017 16:34:18 +0000 2017-02-14 16:34:22      CLIENT -> SERVER: To: User 2017-02-14 
16:34:22    CLIENT -> SERVER: From: yahoo 2017-02-14 16:34:22   CLIENT -> SERVER: Subject:
 Subject: Here is the subject 2017-02-14 16:34:22   CLIENT -> SERVER: Message-ID: <612e33637d0c6d82ec72f3a70bc1b79c@localhost> 2017-02-14 
16:34:22    CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.22 (https://github.com/PHPMailer/PHPMailer) 2017-02-14 16:34:22
CLIENT -> SERVER: MIME-Version: 1.0 2017-02-14 16:34:22 CLIENT -> SERVER:  Content-Type: multipart/alternative; 2017-02-14 16:34:22 
CLIENT -> SERVER: boundary=
"b1_612e33637d0c6d82ec72f3a70bc1b79c" 2017-02-116:34:2
CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 2017-02-14 16:34:22           CLIENT -> SERVER: 2017-02-14 16:34:23   
CLIENT -> SERVER: QUIT Message has been sent

Solution

  • delete this line:

    $mail->SMTPDebug = 1;    
    

    or change the value to 0 or 3

    • 0 = nothing
    • 1 = errors and messages
    • 2 = messages only
    • 3 = nothing