title: PHP send mail error : Header must be an array
body: <p>Below is the code for sending mail directly from form but it is not working.</p>
  
  <pre><code>&lt;?php
  ini_set("include_path", '/home/ny1zdip8aag5/php:' . ini_get("include_path") );
  include('Mail.php');
  if (isset($_POST['submit'])) {
  
      $name = $_POST['name'];
      $email = $_POST['email'];
      $mobile = $_POST['mobile'];
      $address = $_POST['address'];
      $pan = $_POST['pan'];
      $aadhar = $_POST['aadhar'];
      $comp = $_POST['comp'];
      $amount = $_POST['amount'];
      $loss = $_POST['loss'];
      $message = $_POST['message'];
  
  
      $email_from = 'support@picors.com';//&lt;== update the email address
      $email_subject = "New Form submission from $name";
      $email_body = "You have received a new message from the user $name.\n".
          "Here is the message:\n $message".
          "E-mail:\n $email".
          "Mobile:\n $mobile".
          "Address:\n $address".
          "PAN:\n $pan".
          "AADHAR:\n $aadhar".
          "Complainant Company Name:\n $comp".
          "Service Amount Paid To Company:\n $amount".
          "Loss Amount:\n $loss".
  
      $to = "suport@picors.com";//&lt;== update the email address
      $headers = array ('From' =&gt; $email,
        'To' =&gt; $email,
        'Subject' =&gt; $name);
      $host = "**************";
      $username = "*************";
      $password = "***********";
      $smtp = Mail::factory('smtp',
        array ('host' =&gt; $host,
          'auth' =&gt; "PLAIN",
      'socket_options' =&gt; array('ssl' =&gt; array('verify_peer_name' =&gt; false)),
          'username' =&gt; $username,
          'password' =&gt; $password));
          $mail = $smtp-&gt;send($to,$email_subject,$email_body,$headers);
      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>
  
  <p>Below is the code of form.</p>
  
  <pre><code>&lt;form method="post"&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="text" name="name" class="form-control input-text" id="name" placeholder="Your Name" data-rule="minlen:4" data-msg="Please enter at least 4 chars" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="email" class="form-control input-text" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="text" class="form-control input-text" name="mobile" id="mobile" placeholder="Mobile Number" data-rule="minlen:4" data-msg="Please enter valid mobile number" /&gt;
  
      &lt;div class="form-group"&gt;
          &lt;input type="text" class="form-control input-text" name="address" id="Address" placeholder="Address" data-rule="minlen:4" data-msg="Please enter address here" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="text" class="form-control input-text" name="pan" id="pan" placeholder="PAN Number" data-rule="minlen:4" data-msg="Please enter PAN number here" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="text" class="form-control input-text" name="aadhar" id="aadhar" placeholder="ADHAAR Number" data-rule="minlen:4" data-msg="Please enter ADHAAR Number here" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="text" class="form-control input-text" name="comp" id="comp" placeholder="Complainant Company Name" data-rule="minlen:4" data-msg="Please enter complainant company name here" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="text" class="form-control input-text" name="amount" id="amount" placeholder="Service Amount Paid To Company" data-rule="minlen:4" data-msg="Please enter service amount paid to company here" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;input type="text" class="form-control input-text" name="loss" id="loss" placeholder="Loss Amount" data-rule="minlen:4" data-msg="Please enter loss amount here" /&gt;
  
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;textarea class="form-control input-text text-area" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Message"&gt;&lt;/textarea&gt;
  
      &lt;/div&gt;
  
      &lt;div class="text-center"&gt;&lt;input type="submit" name="submit" class="btn btn-default submit" value="Send Message" align="middle"/&gt;&lt;/div&gt;
  </code></pre>
  
  <blockquote>
    <p>Error : $headers must be an array</p>
  </blockquote>