linux msmtp configuration sends from shell but fails from PHP/apache

前端 未结 6 1318
萌比男神i
萌比男神i 2020-12-19 20:41

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

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-19 21:27

    Sorry for the late reply. I also struggled with this issue my self. The problem was the file permissions on the configuration file.

    If you remember correctly you we're asked to chmod the file to 0600 because it wouldn't work otherwise. And you probably created that file using a different user than the one of your web-server/php.

    Which means that your web-server or the one controlling PHP cannot read that file to get your email configurations.

    Also if you created your configuration file under ~/.msmtprc that also won't work. Because when used with PHP, MSMTP only uses the global one from /etc/msmtprc

    Which means that you must create your config in /etc/msmtprc and then chown the configuration file to match the user of your webs-erver/php.

    Since I was on Debian and I used NGINX I had to make that file accessible to www-data with chown www-data:www-data /etc/msmtprc On CentOS that user might be httpd So make sure you have that user set correctly.

    After doing that I was able to send mails with MSMTP using PHP with no problems.

提交回复
热议问题