-   Slackware (
-   -   msmtp from localhost and php mail (

Bazzaah 10-07-2012 08:44 AM

msmtp from localhost and php mail

I'm trying to set up a website on my machine to test an authenticated register/log-in script. The script needs to send a mail to the registrant.

There are plenty of guides out there but not one I've been able to get working yet - once I've registered, the system fails to send a mail confirming the registrant's e-mail address.

This is what I've done

I have installed the msmtprc to /etc rather than ~ with permissions of 0644.

This is msmtprc;


# Accounts will inherit settings from this section
auth            on
tls              on
tls_trust_file  /usr/share/ca-certificates/mozilla/Thawte_Premium_Server_CA.crt

# gmail
account        default
port          587
auth                on
password      password

A test mail from the command line works just fine.


I changed sendmail path to point to mstmp and mstmprc;


sendmail_path = '/usr/bin/msmtp -C /etc/msmtprc -t'
Then I restart httpd.


# /etc/rc.d/rc.httpd restart
Any help with helping me solve this problem would be much appreciated!

eloi 10-07-2012 04:24 PM


Add this line to your .msmptrc defaults section
(0600 perms would be better):


logfile /path/to/msmtp.log

Open a terminal and run:


# tail -f /path/to/msmtp.log

Open another terminal and run


# tail -f /var/log/httpd/error_log

Do what you do with your php form paying attention
to the logs. PHP errors will appear at httpd error_log.

I've never used msmtp with php, I ignore where could be the problem.

Bazzaah 10-07-2012 05:11 PM

Thanks for the reply, much appreciated.

I'm 99% sure that it's a permissions issue on /etc/msmtprc.

Playing with various permissions I get either 'Permission denied' or 'must be owned by you' in httpd error.log.

I'll try the msmtp man and see what I can find.

eloi 10-08-2012 04:37 AM

Try first this:


# chgrp apache /etc/msmtprc
# chmod 640 /etc/msmtprc

msmtp will ask you to use 600 on user config file.
I ignore if it's required on system config too.
If it still complains try:


# chown apache /etc/msmtprc
# chmod 600 /etc/msmtprc

But if the message appears on httpd error_log
it could be the permissions of the msmtp executable the cause.
On Slackware sendmail uses the gid bit and a smmsp group:


-r-xr-sr-x 1 root smmsp 800040 Apr 24  2010 /usr/sbin/sendmail
Perhaps you should do a trick alike with msmpt executable.

Anyway the above are just workarounds to find the problem.
More late you should investigate the "secure" solution.

All times are GMT -5. The time now is 09:44 PM.