I get this warning sending mails with php Warning: mail(1) [function.mail]: failed to open stream: Permission denied in /home/...
It turns out to be a file permissions problems after all. But not in the scripts, but in the directory.
I ran a chmod -R 777 * and the warning went of. upon further examination I found a file called 1, and this file contained a log of the sent mails.
The warning was php telling me that he was unable to open this file
Solution:
sudo chmod -R 755 *
sudo chmod 777 1
F#$%^% cryptic php error messages