title: Email Only showing code / text with Outlook
body: <p>I am having an issue with Outlook displaying email content and attachments correctly, the email content works fine on mail service providers such as Google Mail or Hotmail etc.</p>
  
  <p>This is the email content outlook produces:</p>
  
  <pre><code>X-Mailer: simpleEmailClass v1.0
  
  MIME-Version: 1.0
  
  Content-Type: multipart/mixed; boundary="13406541204fe8c2284f5aa"
  
  Message-Id: &lt; - removed - &gt;
  Date: Mon, 25 Jun 2012 20:55:20 +0100 (BST)
  
  --13406541204fe8c2284f5aa
  
  Content-Type: multipart/alternative; boundary="13406541204fe8c2284f98f"
  
  
  --13406541204fe8c2284f98f
  
  Content-Type: text/plain; charset="ISO-8859-1"
  
  Content-Transfer-Encoding: quoted-printable
  
  Dear Rachel
  Further to your recent enquiry please accept this email as confirmation of your booking.
  Kind Regards
  Hanna
  
  --13406541204fe8c2284f98f
  
  Content-Type: text/html; charset="ISO-8859-1"
  
  Content-Transfer-Encoding: quoted-printable
  
  
  
  &lt;html&gt;
  &lt;body&gt;
  &lt;html&gt;&lt;body&gt;&lt;p&gt;
  
      &lt;span style="font-family: arial, helvetica, sans-serif; font-size: 12px; "&gt;Dear Rachel&lt;/span&gt;&lt;/p&gt;
  
  &lt;p&gt;
  
      &lt;span style="font-size:12px;"&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;Further to your recent enquiry please accept this email as confirmation of your booking.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
  
  &lt;p&gt;
  
      &lt;span style="font-size:12px;"&gt;&lt;span style="font-family:arial,helvetica,sans-serif;"&gt;Kind Regards&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
  
  &lt;p&gt;
  
      &lt;font face="arial, helvetica, sans-serif"&gt;Hanna&lt;/font&gt;&lt;/p&gt;
  
  &lt;/body&gt;&lt;/html&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  --13406541204fe8c2284f98f--
  
  
  
  --13406541204fe8c2284f5aa
  
  Content-Type: application/pdf; name="invoice.pdf"
  
  Content-Transfer-Encoding: base64
  
  Content-Disposition: attachment; filename="invoice.pdf"
  
  JVBERi0xLjMKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZwovT3V0bGluZXMgMiAwIFIKL1Bh
  
  ^^ This go on and on for a long time, thought it was best not to post it all.
  
  --13406541204fe8c2284f5aa--
  </code></pre>
  
  <p>This email above is what is seen in outlook, in Google Mail, it shows as the HTML version.</p>
  
  <p>This is the code im using for the email class.</p>
  
  <pre><code>&lt;?php
  class sec {
      var $secVersion = '1.0';
      var $to = '';
      var $Cc = array ();
      var $Bcc = array ();
      var $subject = '';
      var $message = '';
      var $attachment = array ();
      var $embed = array ();
      var $charset = 'ISO-8859-1';
      var $emailboundary = '';
      var $emailheader = '';
      var $textheader = '';
      var $errors = array ();
  
      function __construct($toname, $toemail, $fromname, $fromemail) {
          $this-&gt;emailboundary = uniqid ( time () );
          $this-&gt;to = "{$toname} &lt;" . $this-&gt;validateEmail ( $toemail ) . "&gt;";
          $email = $this-&gt;validateEmail ( $fromemail );
          $this-&gt;emailheader .= "From: {$fromname} &lt;{$email}&gt;\r\n";
      }
  
      function validateEmail($email) {
          if (! preg_match ( '/^[A-Z0-9._%-]+@(?:[A-Z0-9-]+\\.)+[A-Z]{2,4}$/i', $email ))
              die ( 'The Email ' . $email . ' is not Valid.' );
  
          return $email;
      }
  
      function Cc($email) {
          $this-&gt;Cc [] = $this-&gt;validateEmail ( $email );
      }
  
      function Bcc($email) {
          $this-&gt;Bcc [] = $this-&gt;validateEmail ( $email );
      }
  
      function buildHead($type) {
          $count = count ( $this-&gt;$type );
          if ($count &gt; 0) {
              $this-&gt;emailheader .= "{$type}: ";
              $array = $this-&gt;$type;
              for($i = 0; $i &lt; $count; $i ++) {
                  if ($i &gt; 0)
                      $this-&gt;emailheader .= ',';
                  $this-&gt;emailheader .= $this-&gt;validateEmail ( $array [$i] );
              }
              $this-&gt;emailheader .= "\r\n";
          }
      }
  
      function buildMimeHead() {
          $this-&gt;buildHead ( 'Cc' );
          $this-&gt;buildHead ( 'Bcc' );
  
          $this-&gt;emailheader .= "X-Mailer: simpleEmailClass v{$this-&gt;secVersion}\r\n";
          $this-&gt;emailheader .= "MIME-Version: 1.0\r\n";
      }
  
      function buildMessage($subject, $message = '') {
          $textboundary = uniqid ( time () );
          $this-&gt;subject = strip_tags ( trim ( $subject ) );
  
          $this-&gt;textheader = "Content-Type: multipart/alternative; boundary=\"$textboundary\"\r\n\r\n";
          $this-&gt;textheader .= "--{$textboundary}\r\n";
          $this-&gt;textheader .= "Content-Type: text/plain; charset=\"{$this-&gt;charset}\"\r\n";
          $this-&gt;textheader .= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
          $this-&gt;textheader .= strip_tags ( $message ) . "\r\n\r\n";
          $this-&gt;textheader .= "--$textboundary\r\n";
          $this-&gt;textheader .= "Content-Type: text/html; charset=\"$this-&gt;charset\"\r\n";
          $this-&gt;textheader .= "Content-Transfer-Encoding: quoted-printable\r\n\r\n";
          $this-&gt;textheader .= "&lt;html&gt;\n&lt;body&gt;\n{$message}\n&lt;/body&gt;\n&lt;/html&gt;\r\n\r\n";
          $this-&gt;textheader .= "--{$textboundary}--\r\n\r\n";
      }
  
      function mime_type($file) {
          return (function_exists ( 'mime_content_type' )) ? mime_content_type ( $file ) : trim ( exec ( 'file -bi ' . escapeshellarg ( $file ) ) );
      }
  
      function attachment($file, $filename = NULL, $direct_input = FALSE, $mime = '') {
          if(!$direct_input)
          {
              if (is_file ( $file )) {
                  $basename = $filename? $filename: basename ( $file );
                  $attachmentheader = "--{$this-&gt;emailboundary}\r\n";
                  $attachmentheader .= "Content-Type: " . $this-&gt;mime_type ( $file ) . "; name=\"{$basename}\"\r\n";
                  $attachmentheader .= "Content-Transfer-Encoding: base64\r\n";
                  $attachmentheader .= "Content-Disposition: attachment; filename=\"{$basename}\"\r\n\r\n";
                  $attachmentheader .= chunk_split ( base64_encode ( fread ( fopen ( $file, "rb" ), filesize ( $file ) ) ), 72 ) . "\r\n";
  
                  $this-&gt;attachment [] = $attachmentheader;
              } else {
                  die ( 'The File ' . $file . ' does not exsist.' );
              }
          }
          else
          {
              $basename = $filename;
              $attachmentheader = "--{$this-&gt;emailboundary}\r\n";
              $attachmentheader .= "Content-Type: $mime; name=\"{$basename}\"\r\n";
              $attachmentheader .= "Content-Transfer-Encoding: base64\r\n";
              $attachmentheader .= "Content-Disposition: attachment; filename=\"{$basename}\"\r\n\r\n";
              $attachmentheader .= chunk_split ( base64_encode ( $file ), 72 ) . "\r\n";
  
              $this-&gt;attachment [] = $attachmentheader;
          }
      }
  
      function embed($file) {
          if (is_file ( $file )) {
              $basename = basename ( $file );
              $fileinfo = pathinfo ( $basename );
              $contentid = md5 ( uniqid ( time () ) ) . "." . $fileinfo ['extension'];
              $embedheader = "--{$this-&gt;emailboundary}\r\n";
              $embedheader .= "Content-Type: " . $this-&gt;mime_type ( $file ) . "; name=\"{$basename}\"\r\n";
              $embedheader .= "Content-Transfer-Encoding: base64\r\n";
              $embedheader .= "Content-Disposition: inline; filename=\"{$basename}\"\r\n";
              $embedheader .= "Content-ID: &lt;{$contentid}&gt;\r\n\r\n";
              $embedheader .= chunk_split ( base64_encode ( fread ( fopen ( $file, "rb" ), filesize ( $file ) ) ), 72 ) . "\r\n";
  
              $this-&gt;embed [] = $embedheader;
  
              return "&lt;img src=3D\"cid:{$contentid}\"&gt;";
          } else {
              die ( 'The File ' . $file . ' does not exsist.' );
          }
      }
  
      function sendmail() {
          $this-&gt;buildMimeHead ();
  
          $header = $this-&gt;emailheader;
  
          $attachcount = count ( $this-&gt;attachment );
          $embedcount = count ( $this-&gt;embed );
  
          if ($attachcount &gt; 0 || $embedcount &gt; 0) {
              $header .= "Content-Type: multipart/mixed; boundary=\"{$this-&gt;emailboundary}\"\r\n\r\n";
              $header .= "--{$this-&gt;emailboundary}\r\n";
              $header .= $this-&gt;textheader;
  
              if ($attachcount &gt; 0)
                  $header .= implode ( "", $this-&gt;attachment );
              if ($embedcount &gt; 0)
                  $header .= implode ( "", $this-&gt;embed );
              $header .= "--{$this-&gt;emailboundary}--\r\n\r\n";
          } else {
              $header .= $this-&gt;textheader;
          }
  
          return mail ( $this-&gt;to, $this-&gt;subject, $this-&gt;message, $header );
      }
  }
  </code></pre>
  
  <p>What can i do so that the email in outlook will only show the plain text or html and the attachment, and not how it is currently showing.</p>
  
  <p>Thanks</p>