title: PHPMailer error: Could not instantiate mail function
body: <p>I've looked through all the old posts on stackoverflow and many on other websites and find lots of posts with the same error, but none of the fixes work.</p>
  
  <p>The following is the error I get:</p>
  
  <blockquote>
    <p>Mailer Error: Could not instantiate mail function.</p>
  </blockquote>
  
  <p>Is there something missing or incorrect?</p>
  
  <pre><code>&lt;?php
  require '../PHPMailer/PHPMailerAutoload.php';
  
  //Create a new PHPMailer instance
  $mail = new PHPMailer;
  
  $mail-&gt;Host     = "smtp.gmail.com"; // SMTP server
  $mail-&gt;Port = 465;
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Username = "censored@gmail.com";
  $mail-&gt;Password = "censored";
  
  $mail-&gt;setFrom('censored@gmail.com');
  $mail-&gt;addReplyTo('censored@gmail.com');
  $mail-&gt;addAddress('censored@gmail.com');
  $mail-&gt;Subject = 'PHPMailer mail() test';
  $mail-&gt;msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
  
  $mail-&gt;AltBody = 'This is a plain-text message body';
  
  if (!$mail-&gt;send()) {
      echo "Mailer Error: " . $mail-&gt;ErrorInfo;
  } else {
      echo "Message sent!";
  }
  ?&gt;
  </code></pre>