While working with the command line, there are times when you might want to manually send an email to communicate one-liner information, say a complex command or an important note to yourself or a friend.
Normally, that requires you to open a web browser, log in to your email account, frame an email containing the required information, and then send it.
That’s too long of a process for a small thing, isn’t it? What if you could do that from the command line itself? Yes, it is possible, and we’ve already discussed a couple of ways to do that in Linux.
In this article, we will discuss three more ways to send email from the command line in Linux.
Sendmail
Sendmail, as you might know, is the classical SMTP server from the world of UNIX. It usually comes pre-installed on many Linux distributions, but if that’s not the case with your Linux box, you can easily install it from standard repositories.
For example, users of Debian-based systems, like Ubuntu, can download and install it using the following command:
sudo apt-get install mailutils
Once installed, you can easily and quickly send an email using the sendmailcommand. Here is an example:
echo “This is a test email again”| sendmail [receivers-email-address]
The above command sends an email containing the text “This is a test email again” to “[receivers-email-address]” (make sure to replace it, including the brackets, with the actual email address of the receiver].
When I used my email address in the above command, I got the following email:
