title: Send an Email with PHP & SMTP - Both Text & HTML
body: <p>I have a code with I'm using to send PHP emails to my recipients. I have found a way to send them a HTML email by including the  'Content-Type' => "text/html" in the header's section. My question is that how will those receive my email, who can't display HTML emails? They will see the HTML code? If so, than how can my mailer application decide, when to send the Plain and when to send the HTML formation?</p>
  
  <p>Here is my code for instance:</p>
  
  <pre><code>&lt;?php
   require_once "Mail.php";
  
   $from = "Example &lt;example@example.com&gt;";
   $to = "example@gmail.com";
   $subject = "Hi!";
   $body = '&lt;html&gt;This is a HTML message...&lt;/html&gt;'
  
   $host = "smtp";
   $username = "user";
   $password = "pass";
  
   $headers = array ('From' =&gt; $from,
     'To' =&gt; $to,
     'Content-Type' =&gt; "text/html",
     'Subject' =&gt; $subject);
   $smtp = Mail::factory('smtp',
     array ('host' =&gt; $host,
       'auth' =&gt; true,
       'username' =&gt; $username,
       'password' =&gt; $password));
  
   $mail = $smtp-&gt;send($to, $headers, $body);
  
   if (PEAR::isError($mail)) {
     echo("&lt;p&gt;" . $mail-&gt;getMessage() . "&lt;/p&gt;");
    } else {
     echo("&lt;p&gt;Message successfully sent!&lt;/p&gt;");
    }
   ?&gt;
  </code></pre>