How to send emails in Php using msmtp and gmail in OSX

This is a quick note in how to use msmtp to send email messages using gmail.

Actually configuring msmtp in OSX  is almost the same steps on Linux variants.

Lets get started, i'll be using msmtp on macports. (Install macports first)

Launch a terminal app, and install msmtp.
taeness:~magictalong: sudo port install msmtp

We also need certificates, so install curl-ca-bundle
taeness:~ magictalong: sudo port install curl-ca-bundle

Create a msmtp configuration in your home directory. (By default msmtp uses /opt/local/etc/msmtprc if a user file configuration does not exists)
taeness:~ magictalong: touch /Users/magictalong/.msmtprc

Launch your favorite editor, copy the default account configuration.
taeness:~ magictalong: vim /Users/magictalong/.msmtprc

account default
port 587
timeout 30
auth on
password maypassword
auto_from off
from testing
tls on
tls_starttls on
tls_trust_file /opt/local/share/curl/curl-ca-bundle.crt
logfile /var/log/msmtp.log

Check msmtp documentation for additional options that you may need.
If you want to enable logging, be sure the file on the logfile option exists,
and have read and write permission.

Change mode the msmtp configuration file no more than user read/write permission
taeness:~ magictalong: chmod 600 /Users/magictalong/.msmtprc

Test msmtprc
taeness:~ magictalong: echo "Hello There" > ~/some_text.txt
taeness:~ magictalong: msmtp -d to_sample_email@gmail.com < ~/some_text.txt (The -d switch for debug output)

Configure your php.ini file, and in the sendmail path option:

sendmail_path = /opt/local/bin/msmtp -C /Users/magictalong/.msmtprc -t

Change the configuration file permission, so the web server could access the configuration file.
Example: My apache web server is invoke via user "nobody", so:

taeness:~ magictalong: chown nobody /Users/magictalong/.msmtprc

Test sending via Php, (I'm using XAMPP as an example, and the test_email.php is a simple email script using the mail function)

taeness:~ magictalong: sudo /Applications/XAMPP/xamppfiles/bin/php -f ~/Projects/test_email.php
taeness:~ magictalong: Email Sent!

If it doesnt work, check the apache error log for details.

Disable keystores on SVN

Sometimes its annoying to input a password for keystores (specially gnome-keyring) everytime you do a svn commit.

Heres how to disable it:

In your ~/.subversion/config

Add a line
password-stores =

Or change the value if your config file has this line
#password-stores= gnome-keyring, kwallet

to

password-stores =