title: PHP mail with gmail example
body: <p>I have the following code that I believe will work, but it requires Mail.php. I installed pear mail, but don't have an example of the Mail.php file. Does anyone have an example? I need help putting it in place so that the code will execute. Thanks</p>
  
  <p>
  
  <pre><code>   require_once "Mail.php";
  
      $from = "&lt;me1@gmail.com&gt;";
      $to = "&lt;me2@gmail.com&gt;";
      $subject = "Test from iyearbook!";
      $body = "Hi,\n\nHow are you?";
  
      $host = "ssl://smtp.gmail.com";
      $port = "465";
      $username = "me@gmail.com";
      $password = "password";
  
      $headers = array ('From' =&gt; $from,
        'To' =&gt; $to,
        'Subject' =&gt; $subject);
      $smtp = Mail::factory('smtp',
        array ('host' =&gt; $host,
          'port' =&gt; $port,
          '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;  &lt;!-- end of php tag---&gt;
  </code></pre>