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

I can send an email through the terminal command ssmtp just fine but I cant send an email through PHP with the mail() function. I have configured it to do so correctly (afaik) through php.ini.

sendmail_path = "/usr/sbin/ssmtp -t -i"

Is my sendmail path. Still not working though. I know the ssmtp command itself works just fine, just not through PHP. It doesnt give any errors or anything.

mail("", "Test", "Testing blah");

Is the code im using in PHP. Im using PHP5 and Apache 2. I have tried restarting the Apache 2 server.

Any ideas? Im using the right config file as I got PHP to echo out the directory to the config file. Thanks!

share|improve this question

According to the manpage there is no -i option to ssmtp.

This blog suggests that the correct setting is:

sendmail_path = /usr/sbin/ssmtp -t
share|improve this answer
Changed it to that and still nothing... Any ideas? – James Heald Jun 12 '13 at 12:25

First off; check /var/log/mail.log and /var/log/mail.err

I had the same problem, and I think what solved it was adding this line to /etc/ssmtp/revaliases:

share|improve this answer

From ssmtp's manpage:

   -t     Read  message, searching for recipients.  ``To:'',  `Cc:'',  and
          ``Bcc:''  lines  will  be  scanned  for  people  to send to. Any
          addresses  in  the  argument list will be suppressed  (not  sup-

Apparently what -t does (should do) is to read recipients from the To: headers inside the message (stdin), instead of command line. - If PHP is expecting this behavior it won't send any recipient addresses as arguments.

Since this option is not supported by ssmtp, no recipients will be found, so no message will be sent. - Again don't expect PHP to add recipient addresses as command line args.

What you need to do is to create a simple bash script that inspects lines starting with "To:" and create additional arguments out of these extracted email addresses.

share|improve this answer

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.