AS201281 Wiki

Your check engine light is on!

User Tools

Site Tools


gnu_linux_config:shell_linux:mutt_client

Client mail Mutt

Mutt est un client mail en mode texte qui peut s'avérer pourtant très puissant. Beaucoup de client mail en mode graphique sont lourds et offrent des fonctionnalités pas toujours nécessaires (calendrier, etc…). Mutt se contente de pouvoir recevoir et envoyer des mails. Pour l'installer sur Debian, on installe une version patchée ainsi que w3m pour avoir un rendu des mails HTML.

aptitude install mutt mutt-patched w3m

La configuration de Mutt se fait via le fichier ~/.muttrc on peut aussi poser des extras de configuration dans le répertoire ~/.mutt. La configuration ci-dessous détaille la manière d'utiliser Mutt avec Gmail.

Fichier .muttrc :

# Account information
set realname = "Le nom à utiliser"

# IMAP settings
set ssl_use_sslv3
set imap_user = "user_gmail"
set imap_pass = "password_gmail"
set imap_keepalive = 120
set timeout = 60
set mail_check = 90

# Account settings
set smtp_url = "smtp://user_gmail@smtp.gmail.com:587/"
set smtp_pass = "password_gmail"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed = "+[Gmail]/Drafts"
set record = "+INBOX"
set mbox = "!"
set trash = "imaps://imap.gmail.com/[Gmail]/Trash"

# Caching
set header_cache = ~/.mutt/cache/headers-gmail
set message_cachedir = ~/.mutt/cache/bodies-gmail
set certificate_file = ~/.mutt/cache/certificates-gmail

# General settings
set check_mbox_size = yes
set move = no
set confirmappend = no
set copy = no
set delete = yes
set index_format = "%5C %Z %[%d%m%y %H%M] %-15.15F %3c %s"
bind index "^" imap-fetch-mail
set editor = 'vim + -c "set textwidth=72" -c "set wrap"' # -c "set nocp" -c "?^$"'
set query_command = "abook --mutt-query '%s'"
macro generic,index,pager \ca "<shell-escape>abook<return>" "launch abook"
macro index,pager A "<pipe-message>abook --add-email<return>" "add the sender address to abook"

# GPG Setup
source ~/.mutt/crypto

# Default Identity
folder-hook . "set from = 'user_gmail@gmail.com'"
folder-hook . "my_hdr Reply-To:"
folder-hook . "set signature='~/.mutt/signature-gmail'"

# View settings
set markers = no # don't put '+' at the beginning of wrapped lines
set pager_index_lines= 5 # how large is the index window?
set sort = 'threads'
set sort_aux = 'reverse-threads'
auto_view text/html

# Colors
color normal	  white default
color attachment  brightyellow default
color hdrdefault  cyan default
color indicator   brightyellow red
color markers	  brightred default
color quoted	  green default
color signature   cyan default
color status	  brightgreen blue
color tilde	  blue default
color tree	  red default
#color header	  brightgreen default ^From:
#color header	  brightcyan default ^To:
#color header	  brightcyan default ^Reply-To:
#color header	  brightcyan default ^Cc:
#color header	  brightblue default ^Subject:
#color body	  brightred default [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+
#color body	  brightblue default (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+

# Shortcuts to mailboxes
bind editor <space> noop
macro index gi "<change-folder>=INBOX<enter>" "Go to inbox"
macro index gd "<change-folder>=Debian<enter>" "Go to Debian mail"
macro index gg "<change-folder>=GSoC<enter>" "Go to GSoC mail"
macro index gG "<change-folder>=GSoC Jigsaw<enter>" "Go to Jigsaw mail"
macro index gj "<change-folder>=java-gnome<enter>" "Go to java-gnome mail"
macro index go "<change-folder>=OpenJDK<enter>" "Go to OpenJDK mail"
macro index ga "<change-folder>=StartCom<enter>" "Go to StartCom mail"
macro index gs "<change-folder>=[Gmail]/Messages envoyés<enter>" "Go to sent mail"
macro index gS "<change-folder>=[Gmail]/Spam<enter>" "Go to spam"
macro index gt "<change-folder>=[Gmail]/Corbeille<enter>" "Go to trash"

# Keyboard bindings to functions
bind index X  "purge-message" # Purge messages bypassing Gmail/Trash

# Header stuff
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
ignore *
unignore from: date subject to cc
unignore x-mailing-list: posted-to:
unignore x-mailer:

#Fcc hooks
fcc-hook "~l" "/dev/null"
fcc-hook "~C user_gmail@gmail.com" "/dev/null"

# Save hooks
save-hook . "=[Gmail]/All Mail"

###########
########### USE ONLY WITH MUTT-PATCHED OR COMMENT OUT FROM HERE TO END OF FILE
###########
#
# set up the sidebar, default not visible
set sidebar_width=22
set sidebar_visible=yes
set sidebar_delim=' '
set sidebar_sort=no

# which mailboxes to list in the sidebar
mailboxes =INBOX ="Debian" ="GSoC" ="GSoC Jigsaw" ="java-gnome" ="OpenJDK" ="StartCom" ="[Gmail]/Messages envoyés" ="[Gmail]/Spam" ="[Gmail]/Corbeille"

# color of folders with new mail
color sidebar_new brightgreen default

# ctrl-n, ctrl-p to select next, prev folder
# ctrl-o to open selected folder
bind index \CP sidebar-prev
bind index \CN sidebar-next
bind index \CO sidebar-open
bind pager \CP sidebar-prev
bind pager \CN sidebar-next
bind pager \CO sidebar-open

# I don't need these. just for documentation purposes. See below.
# sidebar-scroll-up
# sidebar-scroll-down

# ctrl-b toggles sidebar visibility
macro index \CB '<enter-command>toggle sidebar_visible<enter>'
macro pager \CB '<enter-command>toggle sidebar_visible<enter>'

#
# Mario Holbe suggests:
# macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'
# macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>' #

Si l'on utilise une clé GPG pour chiffrer ou déchiffrer des mails, on met dans le fichier ~/.mutt/crypto le contenu suivant :

set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_encrypt_only_command="/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
set pgp_encrypt_sign_command="/usr/lib/mutt/pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
set pgp_import_command="gpg --no-verbose --import -v %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"

# specify the uid to use when encrypting/signing
set pgp_sign_as=uid_of_gpg_key_to_use

# this set the number of seconds to keep in memory the passpharse used to encrypt/sign
# the more the less secure it will be
set pgp_timeout=60

# it's a regexp used against the GPG output: if it matches some line of the output
# then mutt considers the message a good signed one (ignoring the GPG exit code)
set pgp_good_sign="^gpg: Good signature from"

# mutt uses by default PGP/GPG to sign/encrypt messages
# if you want to use S-mime instead set the smime_is_default variable to yes

# automatically sign all outcoming messages
set crypt_autosign
# sign only replies to signed messages
set crypt_replysign

# automatically encrypt outcoming messages
set crypt_autoencrypt=no
# encrypt only replies to signed messages
set crypt_replyencrypt=yes
# encrypt and sign replies to encrypted messages
set crypt_replysignencrypted=yes

# automatically verify the sign of a message when opened
set crypt_verify_sig=yes

Certaines personnes (beaucoup ?) envoient des mails au format HTML. Mutt étant un client en mode texte, il faut passer par w3m (navigateur web en mode texte) pour faire le rendu des mails HTML. Pour cela, il faut créer un fichier ~/.mailcap et y mettre ceci :

text/html;      w3m -I %{charset} -dump %s; nametemplate=%s.html; copiousoutput

Enfin pour rajouter automatiquement une signature à la fin des mails, il faut simplement mettre le contenu de la signature dans le fichier ~/.mutt/signature-gmail.

gnu_linux_config/shell_linux/mutt_client.txt · Last modified: 2021/01/04 20:41 by 127.0.0.1