Forget Mail Clients, Send Email from the Command Line [Linux]

Sending an email is something you often don’t have to think twice about. Simply fire up your email client, be it web or desktop-based, compose a message, enter the receipent’s email address and click “Send”. What if there is a need for you to send email from the command line, say to report the progress (or failure) of a backup process?

In Linux, sending emails from the terminal is really a piece of cake. You will need to setup a mail server though (Postfix or Sendmail). To make it easier, you can just install “mailutils” which will then install Postfix for you and allow you to send email using the “mail” command.

In Ubuntu (or Debian-based) distro, install mailutils with the command:

It will then prompt you to configure Postfix (if it is not already installed).


mailutils configure postfix more steps

And the last thing to configure is the FQDN, which will then be used as the domain name in the “From” field.

mailutils configure postfix fqdn

Once you have installed “mailutils“, you can start to send email from the terminal using the following syntax:

For example, to send an email to "" with the subject "Send email from terminal", the command to use is:


And this is what you will see in your email inbox:

mail received in gmail


Mutt is yet another text-based mail client that you can use to send emails from the Terminal. What makes it better than "mail" is that it comes with additional features like:

  • color support
  • message threading
  • MIME support (including RFC2047 support for encoded headers)
  • PGP/MIME (RFC2015)
  • POP3 and IMAP support
  • etc.

To install mutt, simply use the command:

To get started, run mutt in the terminal:

This will load your email "inbox".

mutt inbox

Press "m" to compose a new email. It will prompt you to enter the recipent's email address.


Next, it will prompt you to enter the Subject.


After that, it will open up a nano text editor where you can compose your message. Click "Ctrl + o" to save and "Ctrl + x" to exit.

Lastly, type "y" to send the email. You should see a "Mail sent" message.


Optionally, you can also attach a file to your email with the "a" keyboard shortcut, or type "c" to add a CC field.

To quit mutt, type "q".

In addition to the "GUI" you see above, mutt can also be used in Bash script via the command line. To send an email using the mutt command:

Did you notice that how similar it is to the "mail" command?

Mutt works with a config file that you can use to pre-configure your mailbox's detail. You can make use of muttrc builder to quickly generate a ".muttrc" file and save it to your Home folder.


Sending email from terminal is not a difficult task, and in some situations, it is a necessity. The good thing is that Linux comes with useful tool that you can use to send email from the terminal. We have covered mail and mutt, but they are not the only programs available. There are still several other applications that you can use to send email from terminal. Let us know which one is your preferred choice.

Image Credit: Tim Morgan

Damien Damien

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.


  1. to add, one can quickly pipe output from a command to mail and use it as a body of the message. for example:

    ps auwxf | mail -s ‘ps output’


      1. Oh, thank you. You have a very nicely designed website. (Mail from your address seems to be going to spam? Just saying if you didn’t know.)

    1. You just have to specify the filepath to the .compress file and use this

      mutt -s "Subject" -a /path/to/file/attachment <

  2. A follow up to this article would be to show how you can send out using smtps since port 25 is blocked by most consumer ISP’s. Then another would be to add authentication to smtps if it’s not part of the previous suggestion.

Comments are closed.