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
php.ini sendmail file reads : sendmail_path = /usr/bin/msmtp --debug -C /etc/msmtprc --read-recipients
there is only one php.ini on the system, used for both CLI and webserver located at /etc/php.ini
permissions on /etc/msmtprc are set to apache:apache 600
the following commands as root work and produce a test email :
- php -r "mail('[email protected]', 'Newest Test Email', 'Test email body');"
- runuser -l apache -c '/usr/bin/msmtp --debug -C /etc/msmtprc --read-recipients < /var/www/html/test.mail' (test.mail includes to and from lines)
but apache/php produces an error when the php mail function is called from the following script:
if (mail('[email protected]', 'Newest Test Email', 'Test email body'))
print "Email successfully sent";
else
print "An error occured";
Log files during error read as follows :
- /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)
/etc/msmtprc contains :
defaults
auth on
tls on
tls_trust_file /etc/pki/tls/cert.pem
account default
host smtp.gmail.com
port 587
user [email protected]
from [email protected]
password [******]
auth on
syslog on
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
I'm seeing this question asked, unanswered, in a number of forums - and even ran into my own question in a site that "scrapes" content from stack overflow - and posting an answer to this question for anyone confused by this issue. While this is not an exact answer to the question, it has something to do with the gnome key-ring support that was added to msmtp, as it is run without a shell and with tls. Unable and unwilling to try and convince the code to act in a way in which it was not designed to, my solution has been, with some resistance, to configure exim for smtp relay instead.