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: Once installed, you can easily and quickly send an email using the sendmail command. Here is an example: 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:

As in my case, the email could land in your spam folder, so be sure to check there. The command we just used contained only the body of the email. You can also add more details like subject, from, and more. For example, the following command contains these extra fields, and can be run as a script: Here is the snapshot of the email I received when the above command was run:

Telnet

You can also use the Telnet command to send an email from the command line. To do so, run the following commands (make sure to replace “[senders-email-address]” and “[receivers-email-address]” with sender’s and receiver’s email address, respectively): At this point, you should see a prompt where you need to enter the body of the email and make sure the message ends with a newline followed by a dot (.). Once done, press enter to send the email, and then type quit to exit the application. In my case, I received the following email:

Ssmtp

SSMTP is a tool which delivers email from a local computer to a configured mailhost (mailhub). Debian users can download and install the program using the following command: Once installed, open the /etc/ssmtp/ssmtp.conf file and edit it to make sure that it contains the following information: As always, make sure to replace “[senders-email-address]” and “[senders-email-login-password]” with appropriate values. Now, to send an email using ssmtp, use the following command: Again, replace “[receivers-email-address]”, “[subject-line-here]”, and “[Body of email]” with appropriate values and send the email by pressing “Ctrl + D.” If you receive the following error, then that’s likely because Gmail is not treating ssmtp as a secure application. To get rid of this error, you need to change a particular setting in your Gmail account – for more information on how to do that, and its potential risks, refer to this Google support page. When I executed the above command, I got the following email:

Conclusion

With this, we have discussed a total of 5 command line tools that you can use to send email from the Linux command line. An important point worth mentioning here is that aside from using these commands to send emails manually from the command line, you can also use them to generate notification emails from scripts. Have you ever used any of these tools? How was your experience? Share your thoughts in the comments below.