a little help for people hitting the same problem that stumped me for the last hour or so: if you are trying to send mail using php's mail()
function, but it is not working and qmail-inject: fatal: read error
in your apache httpd error log, you need to edit /etc/profile.d/qmail-run.sh
and remove (or comment out) the references to QMAILMFTFILE
, log out and back in again (or just unset that environment variable), and stop and restart apache. (this comes via the qmail-run rpm when installing qmail using the rpms on redhat.)
what a dumb setting to make part of the default environment.
Comments
in this particular situation, php is using the qmail sendmail wrapper. but because the QMAILMFTFILE environment variable is set in every user's environment, apache picks up that setting, which eventually trickles out to the sendmail wrapper, which will probably be running as a different user than the environment where QMAILMFTFILE was set, and will then fail when it is unable to open the indicated file.
it's really a combination of a couple of half-assed systems that leads to the problem. (specifically, a silly choice to set QMAILMFTFILE in user's default environments, and /etc/init.d scripts that don't create a clean environment.)
i'd put the majority of the blame at the feet of the qmail-run rpms for setting QMAILMFTFILE, and you're unlikely to encounter the problem if you've installed qmail using anything other than the rpms from qmail.org.
(this entry is mainly for the benefit of the next person trying to search google to figure out why their system is failing. when i was diagnosing what was going on, google didn't pull up any really good results.)
I built qmail from source on Redhat 7.3 and apache/mod_php using Apache Toolkit. I installed the horde/imp webmail system and was able to read my mail but not send anything. I wrote several PHP pages which called mail() or invoked the qmail sendmail interface using exec() but nothing was able to send mail. I found this article and after commenting out QMAILMFTFILE the problem was solved.
Add a comment
Sorry, comments on this post are closed.
I'm not sure about RedHat, but on other distributions (I'm working with Debian, Gentoo and OpenBSD) PHP mail work in fact with /usr/bin/sendmail, not directly with qmail. So in the qmail install instructions is mentioned making /usr/bin/sendmail a simlink to /var/qmail/bin/sendmail