How to setup the email client Mutt to send, receive and read email under CentOS and Ubuntu using a Gmail account as a relay
For authentication, you'll have to do either of two things:
- Generate an application-specific password for your Google Account (your only option if you're using 2FA),
- Turn on less-secure app access (not an option with 2FA)
In gmail, go click the gear icon, go to
Settings, go to the tab
Forwarding POP/IMAP, and click the
Configuration instructions link in
IMAP Access row.
I want to enable IMAP. At the bottom of the page, under the paragraph about configuring your mail client, select
Other. Note the mail server information and use that information for further settings as shown in the next section.
yum install mutt
sudo apt-get install mutt
mkdir -p ~/.mutt/cache/headers mkdir ~/.mutt/cache/bodies touch ~/.mutt/certificates
Create mutt configuration file
Add following configurations
set ssl_starttls=yes set ssl_force_tls=yes set imap_user = "firstname.lastname@example.org" set imap_pass = "PASSWORD" set from="email@example.com" set realname="Your Name" set folder = "imaps://imap.gmail.com/" set spoolfile = "imaps://imap.gmail.com/INBOX" set postponed="imaps://imap.gmail.com/[Gmail]/Drafts" set header_cache = "~/.mutt/cache/headers" set message_cachedir = "~/.mutt/cache/bodies" set certificate_file = "~/.mutt/certificates" set smtp_url = "smtps://firstname.lastname@example.org:PASSWORD@smtp.gmail.com:465/" set move = no set imap_keepalive = 900
Make appropriate changes, like
change_this_user_name to your gmail user name and
PASSWORD to your gmail password. And save the file.
Now you are ready to send, receive and read email using email client Mutt by simply typing
For the first time it will prompt to accept SSL certificates; press
a to always accept these certificates.
Now you will be presented with your Gmail inbox.
a) Generate an APPLICATION-SPECIFIC PASSWORD from your Google Account
b01) Install Mutt Mail User Agent:
apt install mutt
b02) It ins't necessary to do any port forwarding, trigger or Virtual Server modification in your router!
b03) Generate directories as follows:
mkdir -p ~/.mutt/cache/headers
b04) Use the following muttrc config:
nano muttrc on
set from = "email@example.com" set realname = "User Name" set imap_user = "firstname.lastname@example.org" set imap_pass = "pwd" set folder = "imaps://imap.gmail.com:993" set spoolfile = "imaps://imap.gmail.com/INBOX" set postponed ="+[Gmail]/Drafts" set header_cache =~/.mutt/cache/headers set message_cachedir =~/.mutt/cache/bodies set certificate_file =~/.mutt/certificates set smtp_url = "smtps://email@example.com@smtp.gmail.com:465/" set smtp_pass = "pwd" set move = no set imap_keepalive = 900