title: PHP PEAR Mail sends 2 emails
body: <p>This script works, but it sends a blank email when it is visited. Then a real one when submitted. I want to get rid of the first blank one it sends. This is mostly edited code I found here and another place I pieced together to work for my needs.</p>
  
  <pre><code>&lt;?php
  ini_set("include_path", '/home/user/php:' . ini_get("include_path") );
  require_once "Mail.php";
  
  $first_name = $_POST['first_name'];
  $last_name = $_POST['last_name'];
  $email = $_POST['email'];
  $address = $_POST['address'];
  $phone = $_POST['phone'];
  $contact = $_POST['contact'];
  $comments = $_POST['comments'];
  $from = "Info &lt;info@domain.net&gt;";
  $to = "Info &lt;info@domain.net&gt;";
  $subject = "Customer Contact Form";
  $body = "If this works it will be edited a bit \n" . "First Name: " . $first_name . "\n" . "Last Name: " . $last_name . "\n" . "Email: " . $email . "\n" . "Address: " . $address . "\n" . "Phone: " . $phone . "\n" . "Please contact me by: " . $contact . "\n" . "Other Comments: " . $comments;
  
  $host = "mail.domain.net";
  $username = "info@domain.net";
  $password = "emailpassword";
  
  $headers = array ('From' =&gt; $from,
      'To' =&gt; $to,
      '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;
  
  &lt;!DOCTYPE html&gt;
  &lt;head&gt;
  &lt;title&gt;Form submission&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="" method="post"&gt;
  First Name: &lt;input type="text" name="first_name"&gt;&lt;br&gt;
  Last Name: &lt;input type="text" name="last_name"&gt;&lt;br&gt;
  Email: &lt;input type="text" name="email"&gt;&lt;br&gt;
  Address: &lt;input type="text" name="address"&gt;&lt;br&gt;
  Phone: &lt;input type="text" name="phone"&gt;&lt;br&gt;
  Perferred Form of Contact: &lt;input type="text" name="contact"&gt;&lt;br&gt; 
  Message:&lt;br&gt;&lt;textarea rows="5" name="comments" cols="30"&gt;&lt;/textarea&gt;&lt;br&gt;
  &lt;input type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>