Score:0

PHP mail() returning FALSE but whole rainloop works - Postfix, Dovecot, PHP 7.3

ma flag

I had this problem earlier but somehow managed to repair it. One month after I had to reinstall Dovecot and Postfix and the same error appeared.

In my php.ini which is located at /etc/php/7.3/apache2/ is sendmail_path set to

sendmail_path = /etc/postfix

It writes I have a problem with permissions:

user@occamy:/etc$ sudo tail /var/log/mail.warn
Oct 21 16:27:36 localhost postfix/sendmail[20073]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied
Oct 21 16:28:36 localhost postfix/sendmail[20079]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied
Oct 21 16:35:02 localhost postfix/postfix-script[20270]: warning: symlink leaves directory: /etc/postfix/./makedefs.out
Oct 21 16:35:02 localhost postfix/postfix-script[20273]: warning: symlink leaves directory: /etc/postfix/./postfix_ab/makedefs.out
Oct 21 16:35:07 localhost postfix/sendmail[20328]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied
Oct 21 16:35:32 localhost postfix/sendmail[20350]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied
Oct 21 16:37:00 localhost postfix/postfix-script[20565]: warning: symlink leaves directory: /etc/postfix/./makedefs.out
Oct 21 16:37:00 localhost postfix/postfix-script[20568]: warning: symlink leaves directory: /etc/postfix/./postfix_ab/makedefs.out
Oct 21 16:37:07 localhost postfix/sendmail[20623]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied
Oct 21 16:37:15 localhost postfix/sendmail[20625]: fatal: /etc/postfix/dynamicmaps.cf: file open failed: Permission denied

/etc/postfix/dynamicmaps.cf

I had the same problem with main.cf. I resolved it with chmod 775 which is not that good I guess...

Then it writes this permission error. The weirdest thing on it is this progress I am doing to obtain e-mail:

  1. Mail returns FALSE when sending mail()
  2. Changing the whole postfix directory to perm. 775 and sending mail - returns TRUE
  3. Email is not received
  4. Changing back to all of the previous permissions for each file
  5. Email has been magically received but cannot send it again. Aaand repeat from point 1

Also when I set dynamicmaps.cf to chmod 775, sudo postconf -m writes:

btree
cidr
environ
fail
hash
inline
internal
memcache
nis
pipemap
proxy
randmap
regexp
socketmap
static
tcp
texthash
unionmap
unix

and the mysql is missing with those permissions set.

Thank you in an advance for your replies!

Score:0
gu flag

You've customized the sendmail_path parameter without knowing what it does.

From the PHP docs:

Where the sendmail program can be found, usually /usr/sbin/sendmail or /usr/lib/sendmail. configure does an honest attempt of locating this one for you and set a default, but if it fails, you can set it here.

You most likely don't need to tune it as it will work by default if all packages are from the package manager and if you do need to tune it, you certainly can't pass a folder as value.

The permission errors from postfix are likely because the file owners aren't properly setup. As a general rule of thumb, chmod or chown in /etc should be uncommon at least.

Junek avatar
ma flag
Okay, so I should leave sendmail_path blank
Junek avatar
ma flag
There is no change after that EDIT: PHP mail() is returning TRUE, only no e-mail has been received
Ginnungagap avatar
gu flag
You should leave it commented out, not blank as I'm not sure it is interpreted the same way.
Junek avatar
ma flag
Commented out, now mail() returns FALSE
Junek avatar
ma flag
/var/log/mail.err still returns dynamicmaps.cf file open failed: Permission denied I still didn't set the permissions back for main.cf but I guess I'm going to obtain the same fatal err
Ginnungagap avatar
gu flag
List all the rights and owners of your postfix configuration. Did you restore it from a backup?
Junek avatar
ma flag
Yes, It's restored
Junek avatar
ma flag
Todays error says: localhost postfix/sendmail[29797]: fatal: open /etc/postfix/main.cf: Permission denied
Junek avatar
ma flag
Pleeease, still getting only permission error and can do nothing with that.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.