#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids &lt; 1000
# Make this empty to disable rewriting.
root=your-full-gmail-address
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.gmail.com:587
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=localhost
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
UseSTARTTLS=YES
AuthUser=your-gmail-username-here
AuthPass=your-gmail-password-here

3. Setup your users

nano /etc/ssmtp/revaliases

You’ll probably want to set up your local user and root for sending mail:

The default config files for MSMTP are located in SYSCONFDIR/msmtprc and ~/.msmtprc.
Neither the first or the second was created by apt, so I preferred to have a folder in /etc where store more than one config file if needed.
Same for the logs.

sudo mkdir /etc/msmtp
sudo mkdir /var/log/msmtp

Then I’ve created the config file: AndroUbuntu is the name of my server, change it.

Note that you can not use a user configuration file (ie: one under ~/) if you plan on using msmtp as a sendmail replacement with php or something similar. In that case just create /etc/msmtprc, and remove your user configuration (or not if you plan on using it for something else). Also make sure it’s readable by whatever you’re using it with (php, django, etc…)

From the msmtp manual: Accounts defined in the user configuration file override accounts from the system configuration file. The user configuration file must have no more permissions than user read/write

So it’s impossible to have a conf file under ~/ and have it still be readable by the php user.

To test it place this file in your php enabled server or using php-cli.

ou

php -r "mail('pzuraq@gmail.com', 'Test Email', 'Test email body');"

Test : config

/path/to/your/config : /etc/msmtp/AndroUbuntu

I have fix the problem. It was that /root/.msmtprc was with non-accesible right which have to be 600 and the owner www-data