7

PHP Mail function fails after I upgrade my Debian web server to jessie. The software versions are,

Apache2 : 2.4 
Php : 5.6 
Exim4: 4.8

This web server has multiple websites and I use libapache2-mpm-itk module to run php by different users for each website. So www-data is not used.

I get below error when try to send emails using php mail function.

unable to set gid=33 or uid=0 (euid=0): forcing real = effective

Sendmail path is,

sendmail_path   /usr/sbin/sendmail -t -i 

and it points to exim,

/usr/sbin/sendmail -> exim4

I found a solution from http://blog.gaiterjones.com/send-php-mail-ubuntu-upgrade/ and issue resolved when I set below setting with itk module,

LimitUIDRange 0 2000

But allowing to root user is not recommended for shared server like mine.

Is there a better solution?

EDIT: I found an unresolved bug report of this. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=797653

Thank you!

Yasiru G
  • 6,218
  • 5
  • 18
  • 37

2 Answers2

0

According to the error message

unable to set gid=33 or uid=0 (euid=0): forcing real = effective

Using root is likely not necessary, group 33 (probably www-data) should also suffice.

So you should be able to use LimitGIDRange 1 9999 instead of LimitUIDRange.

Cobra_Fast
  • 14,395
  • 8
  • 51
  • 97
  • Thanks for the answer but I have tried LimitGIDRange and it didn't work. I'm also looking for an app that can handle emails between apache and exim. – Yasiru G Apr 05 '18 at 03:24
0

I have resolve this issue. Actual problem is explained here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=797653.

Solution 1:

You can install ssmtp. Debian apt-get will remove exim4 when install ssmtp. So you will have to configure it to use external smtp server. Point php sendmail path like sendmail_path /usr/bin/ssmtp -t -i. This could differ with different distributions.

Solution 2:

You can install esmtp and configure it to use localhost smtp. See /etc/esmtprc. Point php sendmail path like sendmail_path /usr/bin/esmtp -t -i. This could differ with different distributions.

Yasiru G
  • 6,218
  • 5
  • 18
  • 37