Hey guys, recently I just installed msmtp in linux and I even send a mail from the terminal and it worked:

echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t [email protected]

But in php, after editing the php.ini file to have this:

sendmail_path = '/usr/bin/msmtp -t'

and using this piece of code:

if ( mail ( '[email protected]', 'Test mail from localhost', 'Working Fine.' ) ){
echo 'Mail sent';
echo 'Error. Please check error log.';


I get the Mail sent message but don't receive a message in my inbox. Not even in the spam folder. Anything wrong I'm doing?

msmtp configuration file:

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 [email protected]
password password
from [email protected]
logfile /var/log/msmtp.log

2 Answers 2


I got the same problem. Your script says the half solution.. Check your apache error logs, not the msmtp ones, if they even exist.. :) My log file said:

"msmtp: /etc/msmtprc: must be owned by you"

Which was correct actually, my msmtp config file at /etc/msmtp was not owned by http.

My php.ini file is like this:

sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc -t"

Hope this helps.


Return Values

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

So, basically this means that message was forwarded to mail transfer tool which in your case is /usr/bin/msmtp. Probably there is nothing wrong with your code. I'd say the appropriate place to look is /var/log/mail.err or other mail related logs.

  • @AndrejsCainikovs my Mail.err is empty. Feb 15, 2011 at 14:58
  • Perhaps logging is done to a different file. First of all, have you configured msmtp? Conf example: msmtp.sourceforge.net/doc/msmtprc.txt Feb 15, 2011 at 15:03
  • Yup I think so: here is what's inside the 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 [email protected] password *** from [email protected] logfile /var/log/msmtp.log Feb 15, 2011 at 15:04
  • Ok, then what /var/log/msmtp.log tells you? Have you tried to execute msmtp from command line just to make sure that it actually works? Feb 15, 2011 at 15:11
  • Yes I did from the command line and it worked( even stated that in my question). I'm checking msmtp.log now. Feb 15, 2011 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .