returning negative values
<p>I have this very simple function...</p>

<pre><code>function send_mail($to, $from, $from_mail, $subject, $message) {

  if ( empty($from) || empty($from_mail) || empty($subject) || empty($message) ) {
      return -1;
  }

  if ( isset ($_SESSION['last_mailed']) )
  {
    if ( $_SESSION['last_mailed'] + 180 &lt; time() )
        return -2;
  }
  $_SESSION['last_mailed'] = time();

  if ( !validEmail($from_mail) )
     return -3;

  $from = strip_mail_headers_single($from);
  $from_mail = strip_mail_headers_single($from_mail);
  $subject = strip_mail_headers_single($subject);
  $message = strip_mail_headers_multi($message);

  return mail($to, $subject, $message, "From: $from &lt;$from_mail&gt;\r\n");

}

if ( !empty($_POST) ) {
  $result = send_mail($mail_to, $_POST['from'], $_POST['from_mail'], $_POST['subject'], $_POST['message']);

  if ( $result == -1 ) 
  {
      echo "&lt;p&gt;You need to complete all the fields.&lt;/p&gt;";
  } 
  elseif ( $result == -2 ) 
  {
      echo "&lt;p&gt;You can only send one mail every three minutes.&lt;/p&gt;";
  } 
  elseif ( $result == -3 ) 
  {
      echo "&lt;p&gt;Please enter a valid email address.&lt;/p&gt;";
  } 
  else 
  {
      echo "&lt;p&gt;Mail sent successfully!&lt;/p&gt;";
  }
}
</code></pre>

<p>I am getting some strange results.  The <code>mail()</code> function returns, result is set to 1 and the mail is sent.  However, "<code>if ( $result == -1 )</code>" evaluates to true for some reason and the corresponding error message is printed out. Why is this? Any ideas?</p>
