If you are like me and you are running your Raspberry Pi headless, and don’t want to start up X windows to send a simple email. You are in luck, as this can easily be done from the command line. And it is very easy to setup.
Note; This is only to send email, and not receive.
– Install SSMTP
pi@raspberrypi ~ $sudo apt-get update
pi@raspberrypi ~ $sudo apt-get install ssmtp
pi@raspberrypi ~ $ sudo nano /etc/ssmtp/ssmtp.conf
Add add these lines;
Use your email address for root, and your gmail username and password for AuthUser and AuthPass.
To send an email
To send an email, run SSMTP with the recipients name.
SSMTP will then wait for you to type your email. It has to be formatted as shown below. And once done, press Ctrl-D to send.
pi@raspberrypi ~ $ ssmtp firstname.lastname@example.org
subject: this is a test
pi@raspberrypi ~ $
Send an attachment
It is also possible to send attachments. This can be done using mpack
pi@raspberrypi ~ $sudo apt-get install mpack
To send a file with an attachment;
pi@raspberrypi ~ $ mpack -s subject picture.png email@example.com