How to Send Emails Using the Command Line in Linux

Nowadays, almost everyone is using email which has overtaken the medium of text messages to become the most effective method of communication. Various mailing services have been established worldwide, and they let you access their services on websites. Some even have apps for different platforms like Gmail and Outlook for Windows, mac, and Android.

In Linux, you can use the terminal to send the emails; it is indeed an efficient method. Furthermore, you can use the terminal to automate the emails, notify others, and integrate the emailing functionalities in your programs. So, in this quick guide, we included a simple approach to sending emails using the command line in Linux.

How to Send Emails Using the Command Line in Linux

Linux requires installing a mail server or agents to send the mail using the command line. Certainly, it supports various applications to send the emails quickly.

1. The Mail Command

The “mail” command is a part of the “mailutils” package. You can install it through the following command:

sudo apt update && sudo apt install mailutils -y

It opens a graphical interface inside the terminal to set up the application during installation. There, you need to follow the onscreen instructions to complete the process.

Now, you can send a mail by entering the following command:

mail -s “Mail_Subject” recipient’s_mail_address

The “-s” option is solely used to specify the subject. Upon execution, it opens an interactive shell where you can add CC and compose the mail. Then, you can press the “CTRL + D” keys to send it.

2. Sendmail

The Sendmail application lets you send the mail using its server’s SMTP (Simple Mail Transfer Protocol). Go through the following steps to install it on your device:

Sudo apt install sendmail -y

Configure Sendmail according to your preferences and run the “sendmail” command to send an email.

sendmail -v recipient’s_mail_address (press Enter)
Your_mail_address (press Enter)
Subject (press Enter)
Message (press Enter)

When you are done typing your message, type “.” in the following line. Then, upon pressing “Enter”, your system will send this mail to the recipient.

3. The Mutt Command

Mutt is a graphical interface utility that allows you to send the emails through the command line. To run it, go through the following commands:

sudo apt install mutt -y
mutt -s “Subject” recipient’s_email_address

Upon executing the previous command, press “Enter” twice to confirm the email address and subject. It then opens a text file to let you type the mail content. After that, just exit the text file to be redirected to Mutt’s interface. Finally, you can send this email by pressing “y”.


Nowadays, emails play an essential role in helping everyone contact the professionals and your office team. Hence, Linux offers a simple way to send emails from the terminal. Thus, this quick guide is all about the tools that you can use to send emails using the command line in Linux. Here, we explained the three simple methods to send emails from your Linux terminal.


Leave a Comment