I am setting up a CentOS 7 Server with Apache2, MySQL, PHP and Postfix (for sending emails over PHP)

My problem at the moment is that I get the following error (at the error_log from Apache):

sendmail: fatal: open /etc/postfix/main.cf: Permission denied

The file /etc/postfix/main.cf has the following permissions: -rw-r--r-- (622)

The directory /etc/postfix has the following permissions: drwxr-xr-x (755)

The owner of this directory is root.

Have I missed something?

  • Why would Apache need to write to that file? Did you modify anything in /etc/postfix without running a make? – Gerard H. Pille May 30 '18 at 12:36
  • Are you serious that /etc/postfix/main.cf is a directory? – Gerard H. Pille May 30 '18 at 12:45
  • I did not modify /etc/postfix. – yfain May 30 '18 at 12:46
  • /etc/postfix/main.cf is a file, I know ;) – yfain May 30 '18 at 12:46
  • Do you expect to send mail without configuring postfix? What is the most recent file in /etc/postfix? What are you trying to do when you get that error? – Gerard H. Pille May 30 '18 at 12:52

You might need to adjust SELinux policy to allow apache to send mail. Easiest way is to turn on httpd_can_sendmail boolean [1].

semanage boolean -m --on httpd_can_sendmail
  • This works for me. Thanks a lot guy! - Have I to make some other important settings? – yfain May 30 '18 at 12:56
  • No other adjustments are necessary if the specific boolean sovles your issue. You might find the documentation (man httpd_selinux) useful if you need to make other adjustments. – sebasth May 30 '18 at 13:04

I think you'd need 755 permissions on the child-items of the folder as well. as for postfix is not in the root-group.

chmod -Rf 755 /etc/postfix
  • Did you mean -R ? Or did you hide the error messages on purpose? – Gerard H. Pille May 30 '18 at 12:37
  • -R you're right, sry^^ – origins523 May 30 '18 at 12:39
  • 1
    You'd better edit your reply, allthough I don't know if /etc/postfix has subfolders. The error isn't referring to a subfolder though, main.cf is a file, not a "direction". – Gerard H. Pille May 30 '18 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.