title: linux msmtp configuration sends from shell but fails from PHP/apache
body: <p>linux (fedora 20) msmtp configuration sends from shell but fails from PHP/apache, I am stumped... my objective is just to send email, through my gmail smtp from my localhost development webserver, to test output of code that sends mail</p>
  
  <p>php.ini sendmail file reads :
  sendmail_path = /usr/bin/msmtp --debug -C /etc/msmtprc --read-recipients</p>
  
  <p>there is only one php.ini on the system, used for both CLI and webserver located at /etc/php.ini</p>
  
  <p>permissions on /etc/msmtprc are set to apache:apache 600</p>
  
  <p>the following commands as root work and produce a test email :</p>
  
  <ul>
  <li>php -r "mail('emily@emilytench.net', 'Newest Test Email', 'Test email body');"</li>
  <li>runuser -l apache -c '/usr/bin/msmtp --debug -C /etc/msmtprc --read-recipients &lt; /var/www/html/test.mail'  (test.mail includes to and from lines)</li>
  </ul>
  
  <p>but apache/php produces an error when the php mail function is called from the following script:</p>
  
  <pre><code>if (mail('emily@emilytench.net', 'Newest Test Email', 'Test email body'))
  print "Email successfully sent";
  else
  print "An error occured";
  </code></pre>
  
  <p>Log files during error read as follows :</p>
  
  <ul>
  <li>/var/log/httpd/error_log : 
        msmtp: cannot connect to smtp.gmail.com, port 587: Permission denied
        msmtp: could not send mail (account default from /etc/msmtprc)</li>
  </ul>
  
  <p>/etc/msmtprc contains :</p>
  
  <pre><code>defaults
  auth on
  tls on
  tls_trust_file /etc/pki/tls/cert.pem
  account default
  host smtp.gmail.com
  port 587
  user emily@emilytench.net
  from emily@emilytench.net
  password [******]
  auth on
  syslog on
  </code></pre>
  
  <p>any pointers in the correct direction are welcomed... only trying to achieve a simple avenue for localhost php mail function to send emails through my gmail smtp server - this is not a production server configuration, it is my local apache/php webserver for web development</p>