title: PHP mail() function returning false, but with no error
body: <p>I am using php's mail() function for the simple process of E-Mailing the input of a contact form to the respective person. The strange thing is that the form always used to process the E-Mails, but one day this all stopped, now the function returns false, but gives no error at all.</p>
  
  <p>The site is on a shared host. When asked about this, they recommended I use the smtp relay xx.xxx.x.xxx</p>
  
  <p>Correct me if I am wrong, but the mail() function does not provide provisions for this does it? Surely it is up to the HOST machine to have it's relays configured correctly?</p>
  
  <p>My question is this: Does this seem like an error with the host config, or is it my code? Here is a sample of the mail code I have used:</p>
  
  <pre><code>$to = "xxx@xxx.co.za"; //to who?
  $subject = "Website Contact: $mysubject";
  $headers .= "MIME-Version: 1.0\r\n";
  $headers .= "From: $fname&lt;$email1&gt;\r\n";
  $headers .= "Reply-To: $email1\r\n";
  $headers .= "Return-Path:$email1\r\n";
  $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  $headers .= "Content-Transfer-Encoding: quoted-printable\r\n";
  $msg2 = nl2br($msg);
  
  $send = mail($to, $subject, $msg2, $headers); //process mail
  
  if(!$send):
    //error stuff here
  endif;
  </code></pre>
  
  <p>Many thanks,
  Simon</p>
  
  <p><strong>@eisberg</strong> - I use a custom error handler like this:</p>
  
  <pre><code>//error handler function
  function customError($errno, $errstr){
  $err = "\n".date('Y-m-d H:m:s')." Error: [$errno] $errstr";
  $fh = fopen("errlog.txt", 'a+');
  fwrite($fh, $err);
  fclose($fh);
  }
  set_error_handler("customError", E_ALL);
  </code></pre>
  
  <p>Would that mean I need to change <code>set_error_handler("customError", E_ALL);</code> to <code>set_error_handler("customError", -1);</code> ?</p>