1

I try to install on a server a msmtp whiwh work with Gmail SMTP.

My .msmtprc file :

defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host smtp.gmail.com
port 587
auth on
user thetranslationtrustee@linguacustodia.com
password XXXXXX
from thetranslationtrustee@linguacustodia.com
logfile /var/log/msmtp.log

My php.ini file have this line :

sendmail_path = /usr/bin/msmtp  -C /root/.msmtprc -t

the command :

msmtp arnaud.gicquel@linguacustodia.com
test
test
test
test

work perfectly and send a mail

but

>cat test_mail.php
 <?php
        if ( mail ( 'arnaud.gicquel@linguacustodia.com', 'Test mail from localhost', 'Working Fine.' ) ){
        echo 'Mail sent ';
        }

        else{
        echo 'Error. Please check error log.';
        }

?>
>php test_mail.php
Mail sent 

seems to work but i never receive the mail

Anyone can help me to configure Msmtp to use Gmail as SMTP relay please

user1895140
  • 109
  • 1
  • 7

2 Answers2

1

I have fix the problem. It was that /root/.msmtprc was with non-accesible right which have to be 600 and the owner www-data

user1895140
  • 109
  • 1
  • 7
1

I type

sendmail_path = /usr/bin/msmtp -t

(witout Parameter -C)

into the php.ini file.

Then

mail ($to, $subject, $body, $from)

works.

Ingo
  • 5,239
  • 1
  • 30
  • 24