title: how to find out if PHP and sendmail are working together?
body: <p>When I use the terminal to send an e-mail things work correctly. I use the following command:</p>
  
  <pre><code>echo "Subject: test" | /usr/lib/sendmail -v you@domain.com
  </code></pre>
  
  <p>But when I try this in PHP:</p>
  
  <p>PHP DOCUMENTATION: </p>
  
  <pre><code>&lt;?php bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) ?&gt;
  </code></pre>
  
  <p>MY IMPLEMENTATION:</p>
  
  <pre><code>&lt;?php mail("you@domain.com", "my topic", "my message contents", "From: me@domain.com"); ?&gt;
  </code></pre>
  
  <p>, then it is not working. Why is that? I guess it has to do with PHPs php.ini file?</p>
  
  <p>All I configured:</p>
  
  <ul>
  <li><p>open php.ini:</p>
  
  <p><code>nano /etc/php5/apache2/php.ini</code></p></li>
  <li><p>uncomment sendmail_path and write:</p>
  
  <p><code>sendmail_path = /usr/sbin/sendmail</code></p></li>
  <li><p>uncomment sendmail_from and write:</p>
  
  <p><code>sendmail_from = me@domain.com</code></p></li>
  <li><p>restart apache:</p>
  
  <p><code>/etc/init.d/apache2 restart</code></p></li>
  </ul>
  
  <p>What can be the case? To make this extra clear: I want PHP to be able to e-mail!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <ul>
  <li>The PHP mail() function returns a FALSE. </li>
  <li>for php.ini: changing <code>/usr/sbin/sendmail</code> into <code>/usr/lib/sendmail</code> (or the other way around) does not seem to make any difference</li>
  <li>for terminal command: changing <code>/usr/sbin/sendmail</code> into <code>/usr/lib/sendmail</code> (or the other way around) does not seem to make any difference either</li>
  <li>I sent messages to both my own domain and to gmail, both without messages in the spam folder.</li>
  </ul>
  
  <p>The logfiles of Sendmail:</p>
  
  <pre><code>root@machine:/var/log# cat mail.warn
  
  root@machine:/var/log# cat mail.err
  
  root@machine:/var/log# cat mail.log
  Mar 20 10:17:09 machine sendmail[12249]: p2K9H2R9012249: from=root, size=0, class=0, nrcpts=1, relay=root@localhost
  Mar 20 10:17:20 machine sendmail[12253]: p2K9HImw012253: from=root, size=0, class=0, nrcpts=0, relay=root@localhost
  Mar 20 10:17:25 machine sendmail[12255]: p2K9HOAC012255: from=root, size=0, class=0, nrcpts=1, relay=root@localhost
  Mar 20 10:20:00 machine sendmail[12277]: p2K9K09k012277: from=root, size=14, class=0, nrcpts=3, msgid=&lt;201103200920.p2K9K09k012277@machine.domain.com&gt;, relay=root@localhost
  Mar 20 10:20:00 machine sm-mta[12279]: p2K9K0Ge012279: &lt;-r@machine.domain.com&gt;... User unknown
  Mar 20 10:20:00 machine sendmail[12277]: p2K9K09k012277: to=-r, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=90014, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
  Mar 20 10:20:00 machine sm-mta[12279]: p2K9K0Ge012279: from=&lt;root@machine.domain.com&gt;, size=290, class=0, nrcpts=2, msgid=&lt;201103200920.p2K9K09k012277@machine.domain.com&gt;, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
  Mar 20 10:20:00 machine sm-mta[12279]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
  Mar 20 10:20:02 machine sm-mta[12279]: p2K9K0Ge012279: to=&lt;you@domain.com&gt;, ctladdr=&lt;root@machine.domain.com&gt; (0/0), delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=60290, relay=gmail-smtp-in.l.google.com. [74.125.77.27], dsn=2.0.0, stat=Sent (OK 1300612802 w59si3196382eeh.92)
  Mar 20 10:20:02 machine sm-mta[12279]: STARTTLS=client, relay=aspmx.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
  Mar 20 10:20:04 machine sm-mta[12279]: p2K9K0Ge012279: to=&lt;you2@domain.com&gt;, ctladdr=&lt;root@machine.domain.com&gt; (0/0), delay=00:00:04, xdelay=00:00:02, mailer=esmtp, pri=60290, relay=aspmx.l.google.com. [74.125.79.27], dsn=2.0.0, stat=Sent (OK 1300612804 p50si3196335eei.44)
  Mar 20 10:20:04 machine sendmail[12277]: p2K9K09k012277: to=you2@domain.com,you@domain.com, ctladdr=root (0/0), delay=00:00:04, xdelay=00:00:04, mailer=relay, pri=90014, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p2K9K0Ge012279 Message accepted for delivery)
  Mar 20 10:20:04 machine sendmail[12277]: p2K9K09k012277: p2K9K09l012277: DSN: User unknown
  Mar 20 10:20:04 machine sm-mta[12279]: p2K9K0Gg012279: from=&lt;&gt;, size=1921, class=0, nrcpts=1, msgid=&lt;201103200920.p2K9K09l012277@machine.domain.com&gt;, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
  Mar 20 10:20:05 machine sm-mta[12279]: p2K9K0Gg012279: to=&lt;root@machine.domain.com&gt;, delay=00:00:01, xdelay=00:00:01, mailer=local, pri=31921, dsn=2.0.0, stat=Sent
  Mar 20 10:20:05 machine sendmail[12277]: p2K9K09l012277: to=root, delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=31038, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p2K9K0Gg012279 Message accepted for delivery)
  Mar 20 10:25:11 machine sendmail[12321]: p2K9PBC3012321: from=root, size=14, class=0, nrcpts=1, msgid=&lt;201103200925.p2K9PBC3012321@machine.domain.com&gt;, relay=root@localhost
  Mar 20 10:25:11 machine sm-mta[12323]: p2K9PBLe012323: from=&lt;root@machine.domain.com&gt;, size=318, class=0, nrcpts=1, msgid=&lt;201103200925.p2K9PBC3012321@machine.domain.com&gt;, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
  Mar 20 10:25:11 machine sm-mta[12323]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
  Mar 20 10:25:12 machine sm-mta[12323]: p2K9PBLe012323: to=&lt;you@domain.com&gt;, ctladdr=&lt;root@machine.domain.com&gt; (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=30318, relay=gmail-smtp-in.l.google.com. [74.125.77.27], dsn=2.0.0, stat=Sent (OK 1300613112 u12si3204796eeh.99)
  Mar 20 10:25:12 machine sendmail[12321]: p2K9PBC3012321: to=you@domain.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30014, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p2K9PBLe012323 Message accepted for delivery)
  Mar 20 11:00:17 machine sendmail[12567]: p2KA0HX9012567: from=root, size=20, class=0, nrcpts=1, msgid=&lt;201103201000.p2KA0HX9012567@machine.domain.com&gt;, relay=root@localhost
  Mar 20 11:00:17 machine sm-mta[12568]: p2KA0HNn012568: from=&lt;root@machine.domain.com&gt;, size=324, class=0, nrcpts=1, msgid=&lt;201103201000.p2KA0HX9012567@machine.domain.com&gt;, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
  Mar 20 11:00:17 machine sm-mta[12568]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
  Mar 20 11:00:18 machine sm-mta[12568]: p2KA0HNn012568: to=&lt;you@domain.com&gt;, ctladdr=&lt;root@machine.domain.com&gt; (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=30324, relay=gmail-smtp-in.l.google.com. [74.125.77.27], dsn=2.0.0, stat=Sent (OK 1300615218 w59si3268114eeh.65)
  Mar 20 11:00:18 machine sendmail[12567]: p2KA0HX9012567: to=you@domain.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30020, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p2KA0HNn012568 Message accepted for delivery)
  Mar 20 11:16:23 machine sendmail[12675]: p2KAGNg8012675: from=www-data, size=188, class=0, nrcpts=0, msgid=&lt;201103201016.p2KAGNg8012675@machine.domain.com&gt;, relay=www-data@localhost
  root@machine:/var/log# 
  </code></pre>
  
  <p><strong>EDIT2:</strong></p>
  
  <p>I have found the solution!</p>
  
  <p>It was the config in php.ini, as I expected. </p>
  
  <p>In php.ini:</p>
  
  <p><code>sendmail_path = /usr/sbin/sendmail **-t -i**</code></p>
  
  <p>Now, lets also try to understand why, cause I found the -t at <a href="http://askville.amazon.com/setup-php-mail-Linux-server/AnswerViewer.do?requestId=11987907" rel="noreferrer">this site</a> and then i found the -i in the php.ini file itself. What does -t and -i mean??</p>
  
  <p><code>-t</code> 
     Extract  recipients from message headers. These are added to any recipients specified  on  the  command line. With  Postfix  versions  prior  to 2.1, this option     requires that no recipient addresses are  specified on the command line.</p>
  
  <p><code>-i</code>
     When reading a message from standard  input,  don't treat  a line with only a . character as the end of input.</p>
  
  <p><a href="http://www.postfix.org/sendmail.1.html" rel="noreferrer">source</a></p>
  
  <p>Hope I could help those of you that ran in to similar problems.</p>