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 install ssmtp
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.
subject: this is a test
pi@raspberrypi ~ $
Send an attachment
It is also possible to send attachments. This can be done using mpack
To send a file with an attachment;