Use Gmail through mutt

Source: Internet
Author: User
Tags gmail mail

Mutt is a very mature mailagent, and Gmail is my favorite web application. Gmail is considered to be almost infinite capacity. If mutt is added, the convenient and fast processing capability will become more perfect. In fact, using Gmail to process emails is fast enough. You can use tags to provide powerful search capabilities to speed up mail processing. However, it is not fast enough for me. One of the main reasons is mailinglist, such as [CSS-D], [ubunt-JP], and [Ubuntu-devel]. There are hundreds of emails floating around every day, click-and-read is almost endless. So I decided to use mutt six months ago.

"Mutt is not suitable for everyone, including those who do not understand the basic concepts of email, or those who do not want more configuration. Mutt is not even designed for most 'normal' users, although it can certainly serve them well. For those who only need a mail client that is 'callable' and do not want higher performance, other mail client programs may be suitable for them ."

The above is what Mutt's author said. Therefore, you may not need to read this article. This article only describes Gmail + mutt, which is not applicable to Mutt + msexchange (IMAP), which is an email server used by many companies. If you need this combination, you can Google the Internet again. There are many related articles there.
This solution is a comprehensive tool of mutt + fetchmail + procmail + msmtp, so the configuration is a little complicated. Let's take a closer look.

Role:

  • Mutt ----- mail client (Mua: Mail User Agent)
  • Fetchmail --- processing ing (MRA: Mail retrieval agent)
  • Procmail ---- processing ing (MDA: mail delivery agent)
  • Msmtp ----- sending (MSA: mail sending Agent)

The traditional Sendmail is not used here. It is strange to install a server on a laptop. Lightweight procmail + msmtp can solve the problem.

Preparation:
First, enable the pop function of Gmail. Below is Google's official shoushun.
Http://mail.google.com/support/bin/answer.py? Answer= 13273

Example User:
Name: Big Data Wudang
Email Address: datou.example@gmail.com
Email secret: datoupasswd
Linux User name: datou

Download Email:
Yes, it is download. Fetchmail can download emails from Gmail to a directory on the local machine. Mutt can read the contents of this directory and display the mail content for users. Therefore, the first step to use mutt to read Gmail mail is to use fetchmail to download mail. Before that, you must try to connect to the Gmail mail server. Because goolge uses SSL for authentication to increase security, an SSL authentication file must be configured to complete user authentication.

Configure the SSL authentication file:
$ mkdir -pv $HOME/mail/certs
$ cd $HOME/mail/certs
$ touch Thawte_Premium_Server_CA.pem
$ touch Equifax_Secure_CA.pem
Download these two files from here and save them to the touch location.
$ wget http://www.adamjiang.com/Thawte_Premium_Server_CA.pem
$ wget http://www.adamjiang.com/Equifax_Secure_CA.pem

Refresh your SSL authentication and tell OpenSSL that you have added a new authentication file.
$ c_rehash $HOME/mail/certs
Note: the validity of this authentication file is valid until Google notifies/warns you of the need for a new authentication file. However, the validity period is long, so you don't have to worry about it for the moment.

Configure fetchmail:
$ touch $HOME/.fetchmailrc
Write the following content into this file. Replace the sample user information with your information.
poll pop.gmail.com
with proto POP3
user 'datou.example@gmail.com'
there with password 'datoupasswd'
is 'datou' here
mda "/usr/bin/procmail -d %T"
options
no keep
ssl
sslcertck
sslcertpath /home/datou/mail/certs/

Change the attributes of this file.
$ chmod 600 ~/.fetchmailrc

Configure procmail:
Add the following sentence to your $ home/. bashrc to specify the mail delivery point for all applications.
# Set the MAIL
export MAIL=/var/spool/mail/datou
Replace datou with your Linux user name.
Follow the example below to write a configuration file for procmail.
PATH=/bin:/usr/bin:/usr/local/bin
VERBOSE=off
DEFAULT=/var/spool/mail/datou
MAILDIR=$HOME/mail
LOGFILE=$HOME/.procmaillog
# Recipes below this comment:
:0:
* ^TOmutt-user
mutt
Note that you are not a datou!

Send Email:
$ touch $HOME/.msmtprc
Configure msmtp, as shown in the following example.
account default
host smtp.gmail.com
port 587
from datou.example@gmail.com
tls on
tls_starttls on
tls_trust_file /home/datou/mail/certs/Thawte_Premium_Server_CA.pem
auth on
user datou.example
password datoupasswd
logfile ~/.msmtp.log
Note that datou is messy.
Configure the correct read/write permissions for this file:
$ chmod 600 ~/.msmtprc

Read the email:
$ touch ~/.muttrc
Download the. Mutt file from here and save it to the Touch Location above.
$wget http://www.adamjiang.com/_muttrc
$mv _muttrc $HOME/.muttrc

Change the necessary parts and save the following example as your mutt configuration file. If you are a mutt user, the above example should be enough. If you need further configuration, read the mutt manpage or visit the official mutt website.

Configure the mutt color:
An example is provided. It is applicable to terminals with dark backgrounds. Save the following content to the color file you specified. In the preceding example, the file is '~ /Mutt/mutt_colors '.
color index blue black Motorola
color index brightyellow black Seasar
color index brightwhite brightgreen uclibc
color header brightyellow black subject
color hdrdefault brightwhite black
color quoted brightgreen black
color status white cyan
color indicator default green
color normal brightwhite black
Mutt color configuration is actually the following mode, so you can build your mail according to your needs.
color object foreground background regax
Regular Expression of the background color of the color UI object
For example, the first line in the above example
color index blue black Motorola
In the index, emails containing Motorola are highlighted in blue on the black background. You can change the keywords and colors you like.

Test:
The configuration is basically complete. Now let's test to see if datou affects you. If an error occurs, first check whether the big data affects you.
$ mutt
Use the mutt command to enter mutt. At this time, mutt will remind you whether to create your own mail folder and answer yes or no. After entering mutt, enter:
!fetchmail -v
If there is no problem with the big data, you can see that fetchmail is receiving emails. If you have more than 500 emails in your mailbox, fetchmail may not be able to download them all at once. Please note this. However, the manual method is too stupid, and the efficiency cannot be improved at all. Well, yes, so we need to schedule a Cron task to download the email every five minutes, so that you can get new messages.
$ crontab -e
This command will open a new editor, enter the following line, save and exit.
*/5 * * * * /usr/bin/fetchmail
OK, Mutt + Gmail is configured. Of course, you need some time to adapt to the mutt operation. In addition, you can view the mutt documentation for more help. The following are some simple commands:

? View help enter view email J next K last R Reply D Delete U Delete remove v view attachment

Mutt needs to call elinks or w3m when viewing HTML emails. Therefore, these programs are generally ready in Linux. If not, just install them.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.