2007/10/11

PHP Mail function

I post this few years ago at php site, but post was removed by maintainers.
-----------------------------------------------------
Linux
Known situation mail() not work, but why ???

Try send a simple mail from shell
root@alpha:~# sendmail xxx@yyy.com
strange error ???

collect: Cannot write ./dfg35A7vav022304 (bfcommit, uid=XXX, gid=XXX): Permission denied

queueup: cannot create queue temp file ./tfg35A7vav022304, uid=XXX: Permission denied

Don't mess with permissons on /var/spool
/var/mail /var/spool/mqueue
Just set them follow the instructions from sendmail readme
It seems that when sendmail runs not like a daemon ( without -bd or -bD options ) it doesn't use corect QueueDirectory from /etc/mail/sendmail.cf

The solution is

set this line in php.ini
;For Unix only.You may supply arguments as well (default:'sendmail -t -i').

sendmail_path="/usr/sbin/sendmail -t -i -OQueueDirectory=/var/spool/mqueue/"

That's all. mail() now work fine ))
Hope this will save up somebody's time, because i spent a lot of hours in digging and tearing my hair (and my mother will colapse if she hear what a words i use ))

No comments: