title: How to use phpmailer in combination with html-email-template in codeigniter correctly?
body: <p>I have a problem and i'm really desperate. Here the situation:</p>
  
  <p>I wanna send a newsletter html email via codeigniter. This is my controller:</p>
  
  <pre><code>if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class mail extends CI_Controller {
  
      function __construct(){
  
          parent::__construct();
  
  
      }
  
      function send_email() {
          $this-&gt;load-&gt;view('mail_form');
          $this-&gt;load-&gt;library('phpmailer');
          $this-&gt;load-&gt;helper('url');
          if(isset($_POST['btnsend']))  {
             $mail = new PHPMailer(); // defaults to using php "mail()"
             $mail-&gt;CharSet="UTF-8";
             $path=base_url() . 'assets/mail.html';
             $body=file_get_contents($path);
             $mail-&gt;SetFrom('bla@bla.com','blabla.com');
             address = $_POST['email'];
             $mail-&gt;AddAddress($address, "Guest");
             $mail-&gt;Subject = "bla";
             $mail-&gt;MsgHTML($body);
             $mail-&gt;AddEmbeddedImage('logo.jpg', 'logo', 'logo.jpg','base64','image/jpeg');
            if(!$mail-&gt;Send()) {
                echo "Mailer Error: " . $mail-&gt;ErrorInfo;
            } else {
                echo "A test email sent to your email address '".$_POST['email']."' Please Check Email  and Spam too.";     
  
            }
         }
  
  
     }
  }
  </code></pre>
  
  <p>P.S.:The phpmailer library has to be downloaded first. There is another function index in that script that loads the view.</p>
  
  <p>This is my view where you can leave your mail adress so that you will receive the newsletter:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Send Email&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form enctype="multipart/form-data" method="post" action="&lt;?php  echo base_url('index.php/mail/send_email'); ?&gt;"&gt;
              &lt;table width="461" height="138" border="1"&gt;
                  &lt;tr&gt;
                      &lt;td width="141"&gt;Enter Your Email Here&lt;/td&gt;
                      &lt;td width="187"&gt;
                          &lt;input name="email" id="email" type="text" /&gt;
                          &lt;input type="submit" name="btnsend" id="btnsend" value="Send Email" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt;
                  &lt;/tr&gt;
  
              &lt;/table&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The html-email template consists of some interlaced tables. The template is displayed perfectly when opened within a browser. But when sent via mail it gots
  shred. The well formatted file is displayed incorrectly in the email client. The logo image and the special chars are displayed correctly but in the mail there is displayed a"&lt; meta http-equiv="Content-Type" content="text/html; charset=utf-8">" as text (NOT html code) before the content 
  starts. Some content is missing and some end tags ("") are doubled although in the original html file all is correct. </p>
  
  <p>So where is the error? Is the file_get_contents()-Method not the right one to parse html documents? I already tried to use a different method with
  "file_get_html of the simple html dom (<a href="http://simplehtmldom.sourceforge.net/" rel="nofollow">http://simplehtmldom.sourceforge.net/</a>) but failed to run that library in codeigniter. I'm afraid i cant post the email html template because 
  it's too long and the content contains sensitive information. But i dont think that the error is in the html file. Does anyone has a tip, some links or knows how this script could work?</p>
  
  <p>P.S.: Sorry for my bad English!</p>
  
  <p>Regards</p>