Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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 ( '', '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
port 587
auth on user
password password
logfile /var/log/msmtp.log
share|improve this question

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.

share|improve this answer

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.

share|improve this answer
@AndrejsCainikovs my Mail.err is empty. – Samir Ghobril Feb 15 '11 at 14:58
Perhaps logging is done to a different file. First of all, have you configured msmtp? Conf example: – Andrejs Cainikovs Feb 15 '11 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 port 587 auth on user password *** from logfile /var/log/msmtp.log – Samir Ghobril Feb 15 '11 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? – Andrejs Cainikovs Feb 15 '11 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. – Samir Ghobril Feb 15 '11 at 15:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.