LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   msmtp from localhost and php mail (https://www.linuxquestions.org/questions/slackware-14/msmtp-from-localhost-and-php-mail-4175430951/)

Bazzaah 10-07-2012 07:44 AM

msmtp from localhost and php mail
 
HI

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;

Code:

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

# gmail
account        default
host          smtp.gmail.com
port          587
auth                on
from          address@gmail.com
user          address@gmail.com
password      password

A test mail from the command line works just fine.

/etc/httpd/php.ini

I changed sendmail path to point to mstmp and mstmprc;

Code:

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

Code:

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

eloi 10-07-2012 03:24 PM

Logs?

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

Code:

logfile /path/to/msmtp.log

Open a terminal and run:

Code:

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

Open another terminal and run

Code:

# 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 04: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 03:37 AM

Try first this:

Code:

# 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:

Code:

# 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:

Code:

-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 02:26 PM.