Answer the question
In order to leave comments, you need to log in
Sending mail via msmtp - why does it work from the user's console, but not from the web server?
I installed msmtp on the server (ubuntu 16.04) to send mail via Yandex smtp and I can't debug the disappearance of messages without a trace, which occurs when trying to use mail() in the php files of the web server. In the console everything works fine, I do
php -r "mail('[email protected]', 'Test Subject', 'Test Message');"
and the letter instantly arrives at [email protected] sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -a myaccountname -t"
mail.log = /var/log/maillog
[18-Dec-2017 15:09:30 Asia/Krasnoyarsk] mail() on [/var/www/mydomain.com/html/wp-content/themes/mywebsite/send.php:23]: To: [email protected] -- Headers:
Answer the question
In order to leave comments, you need to log in
Cause of the problem: when sending mail from the console, PHP uses one config (/etc/php/7.0/cli/php.ini), and when calling mail() from the php files of the web server, another one (/etc/php/7.0 /fpm/php.ini). In one of the configs, the correct value of the sendmail_path variable (it is also default):
and in the other, it is incorrect: sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -a default -t"
For this reason, mail was sent from the console, and from php files was not sent.
The solution to the problem is to have /etc/php/7.0/fpm/php.ini have the default value for the sendmail_path variable, even after setting msmtp.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question