PHPMailer Mailer Error: Message body empty or blank screen
<p>Im trying to use PHPMailer and been getting an error that the Message body empty or the screen is blank and does not print that the message has been sent. My folder structure is everything is in the same folder for testing in case anyone needs to know. I have also followed this post but did not seem to work. <a href="https://stackoverflow.com/questions/13816571/phpmailer-mailer-error-message-body-empty">PHPMailer Mailer Error: Message body empty</a></p>

<pre><code>    &lt;html&gt;
&lt;head&gt;
&lt;title&gt;PHPMailer - SMTP (Gmail) basic test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php

//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

require_once('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');
echo $body;
//$body             = preg_replace('/[\]/','',$body);
//$body = "To view the message, please use an HTML compatible email viewer!";

$mail-&gt;IsSMTP(); // telling the class to use SMTP
$mail-&gt;Host       = "mail.yourdomain.com"; // SMTP server
$mail-&gt;SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
$mail-&gt;SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail-&gt;Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail-&gt;Port       = 465;                   // set the SMTP port for the GMAIL server
$mail-&gt;Username   = "no-reply@yourdomain.com";  // GMAIL username
$mail-&gt;Password   = "xxx";            // GMAIL password

$mail-&gt;SetFrom('no-reply@yourdomain.com', 'First Last');

//$mail-&gt;AddReplyTo("name@yourdomain.com","First Last");

$mail-&gt;Subject    = "PHPMailer Test Subject via smtp (Gmail), basic";
$mail-&gt;IsHTML(true);
$mail -&gt;MsgHTML($body);
$mail-&gt;Body = $body;
//$mail-&gt;AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

//$mail-&gt;IsHTML(true);


$address = "someemail@yourdomain.com";
$mail-&gt;AddAddress($address, "John Doe");

//$mail-&gt;AddAttachment("images/phpmailer.gif");      // attachment
//$mail-&gt;AddAttachment("images/phpmailer_mini.gif"); // attachment

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

?&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Contents.html: </p>

<pre><code>&lt;body style="margin: 10px;"&gt;
&lt;div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;"&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;This is a test of PHPMailer.&lt;br&gt;
&lt;br&gt;
This particular example uses &lt;strong&gt;HTML&lt;/strong&gt;, with a &amp;lt;div&amp;gt; tag and inline&lt;br&gt;
styles.&lt;br&gt;
&lt;br&gt;
Also note the use of the PHPMailer logo above with no specific code to handle
including it.&lt;br /&gt;
Included are two attachments:&lt;br /&gt;
phpmailer.gif is an attachment and used inline as a graphic (above)&lt;br /&gt;
phpmailer_mini.gif is an attachment&lt;br /&gt;
&lt;br /&gt;
PHPMailer:&lt;br /&gt;
Author: Andy Prevost (codeworxtech@users.sourceforge.net)&lt;br /&gt;
Author: Marcus Bointon (coolbru@users.sourceforge.net)&lt;br /&gt;
&lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p>I have put the echos in the code for troubleshooting to see if it is getting the data or not. I think this is honestly something to do with Gmail for the mail hosting. But its what they use. Thank you in advanced with any direction you can provide.</p>

<p>Chris </p>