php mail with msmtp and apache isnt working correctly
by gwabber from LinuxQuestions.org on (#4THKR)
Hi all,
At first excuse me for my English, i am Dutch.
I have a problem configurating msmtp with php and apach2 in Debian 10.
When I try to mail with php trough the commandshell, it works. Also if I execute a php page trough the php command with shell, it works. But when I open the page in a browser with apache2 webserver, the mail won't sent. Can anyone help me with this problem?
My sendmail config:
Code:# Set defaults.
defaults
# Enable or disable TLS/SSL encryption.
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# Setup WP account's settings.
account XXXXXXXX
host smtp.gmail.com
port 587
auth login
user XXXXXXX
password XXXXXXXX
from XXXXXXXXX
logfile /var/log/msmtp/msmtp.log
account default :XXXXXXXXXXMy sendmail config in /var/php/7.3/apache2/php.ini:
Code:sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t"my demo_mail.php :
Code:<?php
mail("mail@mail.com","Hello World","Email sent using PHP via msmtp");
?>
Thanks in advance.
Gwabber.


At first excuse me for my English, i am Dutch.
I have a problem configurating msmtp with php and apach2 in Debian 10.
When I try to mail with php trough the commandshell, it works. Also if I execute a php page trough the php command with shell, it works. But when I open the page in a browser with apache2 webserver, the mail won't sent. Can anyone help me with this problem?
My sendmail config:
Code:# Set defaults.
defaults
# Enable or disable TLS/SSL encryption.
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# Setup WP account's settings.
account XXXXXXXX
host smtp.gmail.com
port 587
auth login
user XXXXXXX
password XXXXXXXX
from XXXXXXXXX
logfile /var/log/msmtp/msmtp.log
account default :XXXXXXXXXXMy sendmail config in /var/php/7.3/apache2/php.ini:
Code:sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t"my demo_mail.php :
Code:<?php
mail("mail@mail.com","Hello World","Email sent using PHP via msmtp");
?>
Thanks in advance.
Gwabber.