The simplest answer to sending one-line messages via gmail is to use ssmtp
Install it with the following commands:
sudo apt-get update
sudo apt-get install ssmtp
/etc/ssmtp/ssmtp.conf to look like this:
Send a one-liner like so:
echo "Testing...1...2...3" | ssmtp firstname.lastname@example.org
printf "Subject: Test\n\nTesting...1...2...3" | ssmtp email@example.com
Then, true to *nix, you just get the prompt back in a few seconds.
Check your firstname.lastname@example.org account, and voila, it is there!
This also works well when sending a file, as so:
cat program.py | ssmtp email@example.com
And the program will show up in the mailbox
If the file is a text file, it can have a first line that says
This can be used with various cron jobs can send me data with subject lines indicating the content.
This will work with anything that prepares a message that is piped into ssmtp via stdin.
For more details such as securing these files against other users and such, visit this article:
Send Email from Raspberry Pi Command Line
Be sure to also look down below to the answer posted by
Rui about locking down the
FROM: address that might be changed in formatted message files, if necessary.
Now if only I could figure out how to send SMS the same way.