Sending mail from the Terminal (CLI) on CentOS 7 with Mutt via gmail

So this can actually be a pain on CentOS if you don’t have a few packages installed first.  A few things to note:

You must install mutt, as well as the sasl package.

1.) Install stuff, YUMmy!

sudo yum install mutt postfix cyrus-sasl-plain cyrus-sasl-md5 -y

2.)Configure Mutt

First, create a backup of the original config file

sudo cp /etc/Muttrc /etc/Muttrc.orig

Next, edit the file and add the following to the end:

NOTE: Everything in Green needs to be changed to match your info.

sudo nano /etc/Muttrc


set from = "Your Email ADDRESS"
set realname = "Your NAME"
set imap_user = ""
set imap_pass = "YourPW"
set smtp_url = "smtps://"
set smtp_pass = "YourPW"

# Configuration Settings to send and receive via gmail
set folder = "imaps://"
set spoolfile = "+INBOX"
set imap_check_subscribed
set hostname =
set mail_check = 120
set timeout = 300
set imap_keepalive = 300
set postponed = "+[GMail]/Drafts"
set record = "+[GMail]/Sent Mail"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set auto_tag = yes
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
alternative_order text/plain text/html *
auto_view text/html
bind editor complete-query
bind editor ^T complete
bind editor noop
set smtp_authenticators = 'gssapi:login'
set editor = "nano"

3.) Create the certificate file

mkdir .mutt
touch .mutt/certificates


4.) Test it!


press m to create an email

Anter a to address, a subject, and then in the nano editor, write the body of your email.  When finished, press ctrl+x, y then press y to send the mail.