linux (fedora 20) msmtp configuration sends from shell but fails from PHP/apache, I am stumped... my objective is just to send email, through my gmail smtp from my localhost
I had the symilar error msmtp: /etc/msmtprc: must be owned by you
with openSuse and changing the owner of /etc/msmtprc was not an option since cron and other services use it for other purposes and it resulted with another error msmtp: /etc/msmtprc: must have no more than user read/write permissions
My solution was to:
1) as root create a copy of msmtprc
cp /etc/msmtprc /etc/msmtprc_apache
chown wwwrun:www /etc/msmtprc_apache
chmod 0600 /etc/msmtprc_apache
2) change apache php.ini settings (search for sendmail_path) and force the configuration file (-C option)
sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc_apache -t"
3) comment out in apache php.ini settings
; SMTP = localhost
; smtp_port = 25
For simple testing, as root switch to wwwrun user and test with php
sudo -u wwwrun -s
php -r "mail('test@test.com', 'PHP test', 'Test from PHP as wwwrun user');"