Search code examples
phpemailsendmailssmtp

mail: failed to open stream: Permission denied?


I get this warning sending mails with php Warning: mail(1) [function.mail]: failed to open stream: Permission denied in /home/...

  • using ssmtp and gmail as smtp
  • PHP 5.3.1
  • nothing in the logs (no errors)
  • the mail gets to destination
  • the permissions of the files are rwxrxrx

Permission denied to what?

Even calling something as simple as

mail("mail@domain.com", "subject", "body");

I still getting this warning


Solution

  • 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