Question

I'm using php plugin for PHPMailer. Its version is PHPMailer_5.2.4. I have tested the sample code of PhpMailer site.

 <?php
require_once('PHPMailer_5.2.4/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

//$body             = file_get_contents('contents.html');
//$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "mail.google.com"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 587;                   // set the SMTP port for the GMAIL server
$mail->Username   = "myuser@gmail.com";  // GMAIL username
$mail->Password   = "mypass";            // GMAIL password

$mail->SetFrom('myuser@gmail.com', 'First Last');

$mail->Subject    = "FeedBack";

$mail->MsgHTML("helo hru ");

$address = "whomto@domainname.com";
$mail->AddAddress($address, "MYName");
$mail->Send();


//if(!$mail->Send()) {
  ////echo "Mailer Error: " . $mail->ErrorInfo;
//} 
//else {
  //echo "Message sent!";
//}

?>

After Executing this code, I'm getting the below output. But the mail has received successfully at my receiver mail Address. But I don't want the below output message. How can I rectify it ?

SMTP -> FROM SERVER:220 mx.google.com ESMTP b3sm40861402pbu.38 - gsmtp

SMTP -> FROM SERVER: 250-mx.google.com at your service, [ipAddress] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 CHUNKING

SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS

SMTP -> FROM SERVER: 250-mx.google.com at your service, [ipAddress] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN 250-ENHANCEDSTATUSCODES 250 CHUNKING

SMTP -> FROM SERVER:250 2.1.0 OK b3sm40861402pbu.38 - gsmtp

SMTP -> FROM SERVER:250 2.1.5 OK b3sm40861402pbu.38 - gsmtp

SMTP -> FROM SERVER:354 Go ahead b3sm40861402pbu.38 - gsmtp

SMTP -> FROM SERVER:250 2.0.0 OK 1383737961 b3sm40861402pbu.38 - gsmtp

SMTP -> FROM SERVER:221 2.0.0 closing connection b3sm40861402pbu.38 - gsmtp

Was it helpful?

Solution

Just remove this line of code:

$mail->SMTPDebug  = 2;

It will disable debugging output.

OTHER TIPS

This is just the debug output. Set $mail->SMTPDebug to 0

Your problem is the $mail->SMTPDebug line.

Setting that value tells PHPMailer to output debug data, which is what you're seeing.

Remove that line, and you won't get the output any more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top