Easy methods to Set up and Configure Mutt With Gmail on Linux

Sending email through the Linux terminal is necessary, especially if you are automating email with a shell script. Email programs like Thunderbird and Evolution may seem like the first tools, but they can feel bloated at times. If you are familiar with the command line, you may find it beneficial to send / receive email using Linux's own heart system.

You can configure Gmail and other email clients in Linux to access your mailbox, send email, and reply to emails right from the terminal. To access your mailbox, you must first configure Mutt, which will make your work easier in the long run.

What is mutt?

Mutt is an open source text-based email client used to transfer / receive email between hosts using the Simple Mail Transfer Protocol (SMTP). To install Mutt, you have to follow a few commands and then you will be able to configure your Gmail mailbox with ease.

Mutts features worth billing for

Before you dive in, you'll want to know what makes Mutt so special for Linux. Here are some features that would convince you of Mutt's true zeal as a mailbox handler:

  • It's easy to install and configure.

  • You can send emails with single / multiple attachments directly from the command line.

  • Mutt enables emails to be sent to recipients in the CC and BCC Sections.

  • It fully supports message threading.

  • Use the excellent function of mailing lists.

  • You get support for different mailbox formats like mbox, maildir, MMDF and MH.

  • It is available in at least 20 languages.

  • Mutt supports the DSN (Delivery Status Notification) function.

How to install Mutt on Linux

Since Mutt is not a standard Linux package, you will not find it preinstalled on your system. You have to install the package manually using a package manager.

On Ubuntu and Debian:

sudo apt-get install mutt

You can install Mutt on RHEL / CentOS with YUM:

sudo yum install mutt

To install the package on Fedora:

sudo dnf install mutt

For Arch-based distributions, you can install the package with Pacman:

sudo pacman -S mutt

How to configure Mutt on Linux

As the first configuration step you have to create a few directories in which the system will save mails, headers and certificates after the installation.

Issue the following commands in sequence:

mkdir -p ~ / .mutt / cache / headers
mkdir ~ / .mutt / cache / bodies
Tap ~ / .mutt / certificates

Create the Mutt configuration file with the touch command:

Touch ~ / .mutt / muttrc

Open that muttrc File with your favorite text editor:

sudo nano ~ / .mutt / muttrc

As soon as the editor opens, it's time to enter the IMAP and SMTP details of your mailbox to populate the mailbox's settings for incoming and outgoing emails.

Here are the settings:

set from = "username@gmail.com"
set realname = "First Last"
# IMAP settings
set imap_user = "username@gmail.com"
set imap_pass = ""
# SMTP settings
set smtp_url = "smtps: //username@smtp.gmail.com"
set smtp_pass = ""
# Remote Gmail folder
set folder = "imaps: //imap.gmail.com/"
set spoolfile = "+ INBOX"
postponed set = "+ (Gmail) / drafts"
set record = "+ (Gmail) / Sent Mail"
Set recycle bin = "+ (Gmail) / recycle bin"

This example shows how to set up a Gmail account with Mutt. Make sure you replace Username, First, and Latest in the above snippet with your username, first name and last name of your email address.

Decrypting the commands for e-mail settings

  • Of: Sender's email ID
  • Real name: This is your name that would appear in the email.
  • IMAP_user: This is your email address.
  • IMAP_pass: Your e-mail password, in case you are sure that no one else is accessing your mailbox.
  • SMTP_URL: The first part defines the URL to which your mailbox will send messages for delivery.
  • SMTP_pass: Mailbox password
  • Folder: Location of your mailbox
  • Spooled file: The folder in the mailbox where emails arrive.
  • Postponed: This points to the folder where moved messages (drafts) are saved.
  • recording: The directory where Gmail stores sent messages.
  • rubbish: The directory for storing deleted emails.

Gmail's IMAP and SMTP configuration settings

In most cases, your mailbox's IMAP and SMTP port numbers will remain the same. For best results, always check your mailbox settings before entering the settings in the Editor window.

For those who use Gmail, here are Gmail's mailbox settings:

Now that you've configured everything, it's time to run Mutt and see the magic of your mailbox unfold before your eyes.

How to use Mutt on Linux

Before you can send and receive emails with Mutt, you have to start the application. Start the terminal and enter Mutt to start the application:


To send new emails with Mutt, tap I in the terminal. Mutt asks for the recipient's email address, subject, and message text. You can also attach a file if you want. When you have updated all the details, press Yes to send the email.

1. Send an email with a subject and message text

To include the subject string in your email, use the -s Flag:

mutt -s "test email from mutt" winibhalla234@gmail.com

2. Pipe Mutt with echo

You can implement the echo command with mutt to pass the message body of the email:

echo "body message" | mutt -s "test email from mutt" winibhalla1234@gmail.com

3. Send an email with an attachment

To add a file as an attachment, include the path of the file at the end of the command:

echo "body message" | mutt -s "test email from mutt" winibhalla645@gmail.com test.txt

If you want to attach multiple files, pass the file names separated by the place Character.

echo "body message" | mutt -s "test e-mail from mutt" winibhalla543@gmail.com -a test.tar.gz -a test2.tar.gz

4. Send e-mail to multiple recipients

Similarly, you can also add multiple email addresses to send the email to:

mutt -s "test email from mutt" demo1@muo.com, demo2@muo.com, demo3@muo.com

5. Add recipients in CC and BCC mode

You can use the … -c and -b Flag to specify the carbon copy and blind carbon copy email addresses.

mutt -s "Subject of the email" -c; -b; Mail address of the recipient

In the following example, Mutt uses winibhalla533@gmail.com as the To Address while it is copying and blindly copying the email to winibhalla123@gmail.com or winibhalla234@gmail.com.

mutt -s "test email" -c winibhalla123@gmail.com -b winibhalla234@gmail.com winibhalla533@gmail.com

6. Get command line help

If you get stuck, you can get Mutts help by doing the -H Flag.

Mutt -h

Checking Mutt's email interface

You can use the menu bar at the top of the interface window to navigate between the various tabs. The terminal window also lists the keyboard shortcuts directly below it. The middle area is used to display the message (s).

Unfortunately, Mutt doesn't have a built-in email composer. So you need to use a text editor like Nano, Vim, Emacs, etc. to compose your message body.

You can use the following commands with Mutt:

  • I: Compose a new email
  • q: Leaving
  • d: Clear
  • r: Reply
  • Yes: Send
  • I: Exit

What is special about Mutt?

Mutt is an open source package that does its job, is relatively small, and gets the job done. In spite of the fast processing and ingenious error handling, the representation of images in e-mails falls short.

Since it was created in a text format for quick results, some people might think that Mutt doesn't do the job well for emails with pictures. Even so, if you want a command line email client for Linux, Mutt should be your first choice.

The 10 Best Linux Email Clients

Forget webmail – the best way to manage email is in an email client. But which one? Choose from the 10 best Linux email clients.

Continue reading

About the author

Wini Bhalla
(7 articles published)

Wini is a Delhi based writer with 2 years of writing experience. While writing, she was associated with digital marketing agencies and technical firms. She has written content on programming languages, cloud technology, AWS, machine learning, and much more. In her free time, she enjoys painting, spending time with her family and traveling to the mountains whenever possible.

By Wini Bhalla

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Expand to read the full story

Leave a Reply

Your email address will not be published. Required fields are marked *