Principe

MUA -> MTA -------------> MRA ------> MDA --------------> MUA
mutt > sendmail/postfix > fetchmail > maildrop/procmail > mutt (qui lit le maildir)

Configuration

~/.fetchmailrc (Fetchmail)

Le fichier de conf de fetchmail, qui récupère les mails, et les stocke dans `/var/mail/

set daemon 60
set logfile fetchmail.log

poll ssl0.ovh.net protocol pop3:
     username "adresse1@company.fr" password "xxXxXXx" is "adresse1" here keep mda "/usr/bin/maildrop";
     username "adresse2@company.fr" password "xxXxXXx" is "adresse2" here mda "/usr/bin/maildrop";

Sur adresse1@company.fr, l’option keep après is {name} here sert à laisser les mails sur le servueur une fois ramenés sur la machine.

~/.mailfilter (Maildrop)

La conf de maildrop, qui prend les mails à partir du /var/mail/, et les répartit dans le ~/Maildir

DEFAULT="$HOME/Maildir/"
ADRESSE1="$DEFAULT/adresse1/INBOX/"
ADRESSE2="$DEFAULT/adresse2/INBOX/"

logfile "$HOME/maildrop.log"

if (/^(To|Cc|Bcc|Delivered-To):.*adresse1@company.fr/)
{
  to $ADRESSE1
}

if (/^(To|Cc|Bcc|Delivered-To):.*hello@thomasguesnon.fr/)
{
  to $ADRESSE1
}

to $DEFAULT

.mutt/muttrc (Mutt)

La conf de mutt, qui se contente de lire le ~/Maildir

Envoi

sudo apt-get install sendmail sendmail-bin msmtp

w/ msmtp

# Valeurs par défaut pour tous les comptes.
defaults
auth           on
tls            on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
tls_starttls   off # important, sinon le mail ne part pas via le port 465 (ssl/tls)
syslog	       on
logfile        ~/.msmtp.log

# Exemple pour un compte ovh
account        ovh
host           ssl0.ovh.net
port           465
from           adresse1@thomasguesnon.fr
user           adresse1@thomasguesnon.fr
password       xxXxXXx
timeout	       15

# Définir le compte par défaut
account default : ovh

checker avec mailq

Notifications

Grâce à mail-notifier

sudo apt-get install mail-notifier

Ensuite, on ajoute les dossiers qu’on veut observer Ici, on sait que fetchmail récupère, transmet à maildrop qui ajoute aux dossiers qui vont bien dans le ~/Maildir. Donc, on veut écouter ~/Maildir/{compte}/INBOX. C’est celui-ci qu’on ajoute donc.

Créer un nouveau dossier

Pour créer un nouveau dossier dans le maildir

cd ~/Maildir/someAccount
mkdir -p INBOX.someBox/{cur,new,tmp}

Flags

D : le message est supprimé (marqué pour la suppression)
d : le message a des pièces jointes marquées pour la suppression
K : contient une clé PGP publique
N : nouveau message
O : ancien message
P : le message est chiffré avec PGP
r : une réponse a été envoyée pour ce message
S : le message est signé par PGP et la signature a été verifiée
s : le message est signé par PGP
! : le message a l'indicateur 'important' de positionné
* : le message est marqué
----------
+ : vous êtes l'unique destinataire du message
T : vous êtes destinataire et d'autres personnes ont été placées en 'Cc'
C : une copie carbone du message vous a été adressée
F : vous êtes l'auteur du message
L : une de vos listes de diffusion est destinataire du message

Principaux raccourcis

Mutt Command Context Effect Tutorial Section Relevant muttrc settings
a Sending Message Attaches a file to the message you have created Sending Messages none
b Sending Message Lets you edit the list of blind carbon copy recipients for the message you have created Sending Messages none
c Sending Message Lets you edit the list of carbon copy recipients for the message you have created Sending Messages none
d Main Menu, Reading Message Marks the current message for deletion Deleting Messages none
f Main Menu, Reading Message Forwards the message to another address Forwarding Messages askbcc, askcc, edit_headers, editor
i Reading Message Returns from reading a message to the Main Menu Reading Messages none
j Main Menu Changes the selected message to the next message Getting Around in the Menu color
k Main Menu Changes the selected message to the previous message Getting Around in the Menu color
m Main Menu, Reading Message Creates a new message to send Sending Messages abort_nosubject, abort_unmodified, askbcc, askcc, edit_headers, editor, recall
mutt Command line Starts mutt Getting Into and Out of the Mutt Menu beep-new, color, mark_old, move, sort
p Main Menu, Reading Message Prints the currently selected message Printing Messages print, print_command
q Main Menu Quits mutt Getting Into and Out of the Mutt Menu delete, mark_old, mbox, move
q Sending Message Aborts or postpones the message you have created Sending Messages or Postponing Messages postpone, postponed
r Main Menu, Reading Message Creates a reply to the current message Replying to Messages abort_nosubject, abort_unmodified, askbcc, askcc, edit_headers, editor, include, metoo
s Main Menu, Reading Message Saves the current message to a file Saving Messages folder
s Sending Message Lets you change the subject for the message you have created Sending Messages none
t Sending Message Lets you edit the list of recipients for the message you have created Sending Messages none
u Main Menu, Reading Message (messages marked for deletion only) Removes the deletion mark from the current message Deleting Messages none
x Help Menu Returns from the help menu to the Main Menu Getting Around in the Menu none
y Sending Message Sends the message you have created Sending Messages abort_unmodified, copy, record
? Main Menu Goes from the Main Menu to the Help Menu Getting Around in the Menu color
- Reading Message Moves to the previous page in the message you are reading Reading Messages none
/ Main Menu Prompts for a pattern to search for in the headers of your messages Getting Around in the Menu none
= Main Menu Selects the first message Getting Around in the Menu color, sort
$ Main Menu Deletes all messages selected for deletion, and checks for new messages Deleting Messages beep_new, delete, mark_old, mbox, move
* Main Menu Selects the last message Getting Around in the Menu color, sort
< number > Main Menu Selects message < number > Getting Around in the Menu color
< Enter > Main Menu Brings the currently selected message up on the screen Reading Messages color
< Space > Reading Message Moves to the next page in the message you are reading, or to the first page of the next message not marked for deletion Reading Messages none
< Tab > Main Menu Selects the next new message Getting Around in the Menu color
< Esc > / Main Menu Prompts for a pattern to search for in the bodies of your messages Getting Around in the Menu none
up/down arrow Main Menu Changes the selected message to the previous/next message Getting Around in the Menu color
PageUp/PageDown Main Menu, Reading Message Moves up/down one page in the Main Menu or the message you are reading Getting Around in the Menu or Reading Messages none

Gestion des spams

à gérer au niveau du MDA (pour moi, maildrop). Voir ~/.mailfiter

ajouter au ~/.mailfilter

SPAMS="$DEFAULT/spam/" # dossier des spams ($DEFAULT est $HOME/Maildir/)

# process SPAM
if ((/^X-Spam-Flag: YES/:h) || (/^X-Spam-Status: Yes/:h) || (/^X-Spam-Tag: Yes/:h) )
{
to $SPAMS
}

Divers, utilisation

Détacher un attachement

Dans l’affichage de la structure du message, taper D sur l’attachement qu’on veut détacher.

Déplacer plusieurs messages

  • tag messages : t pour tagger un message, ESC t pour tagger tout un thread
  • tell mutt to apply a function to tagged messages. press ;
; tag-prefix apply next function to tagged messages
  • Save them. press s. Messages are copied to folder, and original ones in main box are marked for deletion.

Rechercher w/ notmuch

sudo apt-get install notmuch-mutt # installe auto notmuch

Dans le muttrc

macro index <F8> \
"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
<shell-escape>notmuch-mutt -r --prompt search<enter>\
<change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
"notmuch: search mail"

donc, en tapant f8 dans mutt, on accède à notmuch. quelques exemples de recherche

from:will@example.com AND to:john@example.com OR to:jane@example.com
date:”2015-09-01″..”2015-09-02″
budget AND FY14 OR FY15 AND date:”2015-09-01″..”2015-09-02″

sur cette ligne de commande, on peut rechercher d’autres critères de recherche avec ? (ou man notmuch-search-terms hors de mutt)

Voir https://notmuchmail.org/notmuch-mutt/

Liens