title: php mail() returning false, but not in command line
body: <p>I've been looking around on stackoverflow and many other websites for ideas, but nothing has worked so far and I need more direct help.</p>
  
  <p>I have a dedicated Ubuntu Server (9.04 jaunty) and I'm running several PHP websites there, with apache2. My problem is that the mail() function has stopped working. Since a while back I've been using PEAR Mail Queue for most emails, so I'm not sure exactly when mail() stopped working, but I still need it for an OpenCart setup, among a few other things, but mail() keeps return false no matter what I do. Even this simple code won't work:</p>
  
  <pre><code>&lt;?php
  mail('mail@example.com','test','test');
  ?&gt;
  </code></pre>
  
  <p>So, I've been looking at the Sendmail-settings in php.ini which all check out, and when I run this in the command line, it works fine and sends me an email:</p>
  
  <pre><code># sendmail
  mail@example.com
  test message
  </code></pre>
  
  <p>So I thought it might be php itself that has a problem, so I try the following command:</p>
  
  <pre><code># php -r "mail('mail@example.com','test','test');"
  </code></pre>
  
  <p>And it also sends the email without any problems! So what could it be? I started thinking it might be some sort of permission problem, that maybe www-data had some issues with running the script. Still not sure about this, because I can't even run this script:</p>
  
  <pre><code>&lt;?php
  echo exec('whoami');
  ?&gt;
  </code></pre>
  
  <p>It also returns false! I've run the <strong>visudo</strong> command and added the following line just in case:</p>
  
  <pre><code>www-data ALL=(ALL) ALL
  </code></pre>
  
  <p>And I've changed the user and group owners of the files from <strong>root:root</strong> to <strong>www-data:www-data</strong> but still nothing!</p>
  
  <p>What else can I try? There must be someting!  Can anyone help me?</p>