Raspberry Pi – Send Mails

Hello everyone, today I want to show you how to setup your Raspberry Pi to send mails via Googles SMTP server (smtp.gmail.com). I struggled a bit with Googles security settings and wanted to let you know how to solve the problems I encountered easily.

Before we begin you should update your Raspberry Pi:

sudo apt-get update

Next install ssmtp and mailutils:

sudo apt-get install ssmtp
sudo apt-get install mailutils

Next we will save the current default ssmtp.conf Configuration file:

sudo mv /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.old

Now we will create a new ssmtp.conf Configuration file:

sudo nano /etc/ssmtp/ssmtp.conf

Now have a look at the Configuration below and replace username and password with your Account data:


Important: If your password contains the character # your Configuration will not work since the character # is used to define comments in the Configuration file. (Source: http://ubuntuforums.org/showthread.php?t=1691878)

Now run the below command to send a mail via ssmtp:

ssmtp <RecipientMailAddress>
Subject: <YourSubject>

or you can use the below command to send a mail via mailutils:

echo "<YourMailText>" | mail -s "<YourSubject>" <RecipientMailAddress>

When you run the above ssmtp command to send your mail you will probably receive an error message like shown in the below screenshot:


The error “ssmtp: Authorization failed (534 5.7.14 …” means that the security settings of your Google Mail Account do not allow ssmtp to send mails.

To solve this problem you need to alter the security settings of your Google Mail Account by turning on the “Access for less secure apps” setting.

You can find this setting here: https://www.google.com/settings/security/lesssecureapps

The settings page should now look like this:


Now try again to send a mail and it should work now without problems.
Well, that´s it. You should now be able to send mails from your Raspberry Pi.

I hope you liked my post and I hope to see you again next time 🙂







Tagged , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: