Problem
I wanted to send an email notification from command line. I launched a program on my desktop machine at my workplace that would require some days to finish. I want to know when it’s finished and I want to get the result too.

Solution
The email will be sent via gmail, it’s the easiest solution. Here, Sid explains nicely how to configure ssmtp on a desktop. Here I repeat the steps:

Step one:
Install ssmtp: “sudo apt-get install ssmtp“.

Step two:
Edit the file /etc/ssmtp/ssmtp.conf and add the following content:

Use Case
In the intro I mentioned that I want to get the result of a slow program. Here is how I did it: the program writes the result in a file called “result.txt“. When it’s finished, a shell script is called that sends the content of result.txt to me: