You can configure Gmail and other email clients within Linux to access your mailbox, send emails, and respond to emails from the terminal directly. To access your mailbox, you will first need to configure Mutt, which will make things easier for you in the long run.
What Is Mutt?
Mutt is an open-source text-based email client used to transfer/receive emails among hosts while using the Simple Mail Transfer Protocol (SMTP). To install Mutt, you need to follow a few commands, and then you can configure your Gmail mailbox with ease.
Mutt’s Features Worth Reckoning
Before you dive in, you would want to know what makes Mutt so special for Linux. Here are some features that would convince you of Mutt’s true mettle as a mailbox handler:
It’s easy to install and configure. You can send emails with single/multiple attachments, right from the command line. Mutt allows you to send mails to recipients in the CC and BCC sections. It wholeheartedly supports message threading. Utilize the excellent feature of mailing lists. You get support for different mailbox formats like mbox, maildir, MMDF, and MH. It’s available in at least 20 languages. Mutt supports the DSN (Delivery Status Notification) feature.
How to Install Mutt on Linux
Since Mutt isn’t a standard Linux package, you won’t find it preinstalled on your system. You’ll have to manually install the package using a package manager.
On Ubuntu and Debian:
You can install Mutt on RHEL/CentOS using YUM:
To install the package on Fedora:
On Arch-based distributions, you can install the package using Pacman:
How to Configure Mutt on Linux
As the first configuration step, you have to create a few directories where the system will store mails, headers, and certificates post-installation.
Issue the following commands one by one:
Create the Mutt configuration file using the touch command:
Open the muttrc file using your favorite text editor:
Once the editor opens up, it’s time to start filling in your mailbox’s IMAP and SMTP details to populate the mailbox’s settings for incoming and outgoing mails.
Here are the settings:
This example demonstrates how to set up a Gmail account using Mutt. Make sure to replace username, First, and Last in the above snippet with your email address username, first name, and last name respectively.
Deciphering the Commands for Email Settings
From: Sender’s email ID Realname: This will be your name, which would appear on the email. IMAP_user: This is your email address. IMAP_pass: Your email password, in case you are sure no one else will be accessing your mailbox. SMTP_url: The first part defines the URL where your mailbox will send messages for delivery. SMTP_pass: Mailbox password Folder: Location of your mailbox Spoolfile: The folder inside the mailbox, where emails arrive. Postponed: This references the folder to store postponed messages (drafts). Record: The directory where Gmail stores sent messages. Trash: The directory to store deleted emails.
Gmail’s IMAP and SMTP Configuration Settings
Most often, your mailbox’s IMAP and SMTP port numbers tend to remain the same. For the best results, it’s always recommended you check your mailbox settings, before keying in the settings in the editor window.
For those who are using 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 unfurl in front of your eyes.
How to Use Mutt on Linux
Before you can send and receive emails with Mutt, you’ll have to launch the application. Start the terminal and type mutt to launch the application:
To send new emails using Mutt, type m in the terminal. Mutt will ask for the recipient’s email address, subject, and message body. You can also attach a file if you want. Once you have updated all the details, press y to send the email.
1. Send an Email With Subject and Body Message
To add the subject string in your email, use the -s flag:
2. Pipe Mutt With echo
You can implement the echo command with Mutt to pass the message body of the email:
3. Send an Email With an Attachment
To add a file as an attachment, specify the path of the file at the end of the command:
If you want to attach multiple files, pass the file names separated with the Space character.
4. Send Email to Multiple Recipients
Similarly, you can also add multiple email addresses to send the email to:
5. Add Recipients in CC and BCC Mode
You can use the -c and -b flag to specify the email addresses for carbon copy and blind carbon copy.
In the example below, Mutt will use winibhalla533@gmail.com as the To address, while it will carbon copy and blind carbon copy the email to winibhalla123@gmail.com and winibhalla234@gmail.com respectively.
6. Get Command-Line Help
In case you feel stuck, you can seek out Mutt’s help using the -h flag.
Reviewing Mutt’s Email Interface
The menu bar at the very top of the interface window allows you to navigate between the various tabs. The terminal window also lists the keyboard shortcuts right below. The middle pane is for viewing the message(s).
Unfortunately, Mutt does not come with an inbuilt email composer, so you need to use a text editor like Nano, Vim, Emacs, etc to create your message body.
You can use the following commands with Mutt:
m: Compose a new email q: Quit d: Delete r: Reply y: Send i: Exit
What’s So Special About Mutt?
Mutt is an open-source package that serves the purpose, is relatively small, and gets the job done. Despite its quick processing and resourceful error handling, it falls short when it comes to displaying images within emails.
Since it’s made in a text format to return fast results, some people might feel Mutt does not do the job well for mails with images. Nevertheless, Mutt should be your first choice if you want a command-line email client for Linux.