Send email with gmail on raspberry pi

26 Aug 2015

Prerequisites

Setup

Install ssmtp:

$ sudo apt-get install ssmtp
$ sudo emacs /etc/ssmtp/ssmtp.conf
root=YOUR_EMAIL
mailhub=smtp.gmail.com:587
hostname=PI_HOSTNAME
AuthUser=YOUR_EMAIL
AuthPass=YOUR_PASSWORD
FromLineOverride=YES
UseSTARTTLS=YES

Install heirloom-mailx:

$ sudo apt-get install heirloom-mailx

Test

Send a mail to DESTINATION_EMAIL:

$ echo This is a test | mail -v -s "A mail from your pi" DESTINATION_EMAIL

External references