Mails en mode console (reception, tri, filtrage, envois)

•La reception avec Fetchmail

$ chmod 600 ~/.fetchmailrc

$ vim ~/.fetchmailrc

---------------------------------------------------------------------------------------------------------------
set postmaster "fred"
set bouncemail

poll pop.free.fr with proto POP3
user fred password 1234

poll pop.online.net with proto POP3
user fred password 1234

poll pop.online.net with proto POP3
user fred password 1234

poll pop.freesbee.fr with proto POP3
user fred password 1234

# Lancement de procmail 
mda "/usr/bin/procmail -Y -d %T"

---------------------------------------------------------------------------------------------------------------
Fetchmail stocke les mails dans un fichier : 

fred@fred1:/var/spool/mail$ ls
fred

Procmail viendra ensuite les rechercher et les dispatcher en fonction des rêgles de triage.

Tri des mails avec Procmail 

vim ~/.procmailrc

--------------------------------------------------------------------------------------------------------

LOGNAME=fred
SHELL=/bin/sh
DEFAULT=$HOME/Mail/boite-reception/
SHELL=/bin/sh

# filtrage

:0fw
 * < 50000
| /usr/bin/spamc

:0:
* ^X-Spam-Status: Yes.*
$HOME/Mail/spam/

# Doublons vers repertoire /spam
:0 Whc: msgid.lock
| formail -D 8192 msgid.cache
:0 a:
$HOME/Mail/spam/

# Attachements indésirables
:0 HB:
* .*name=.*\.(scr|vba|vb|bat|cmd|pif|exe).*
$HOME/Mail/spam/

Activation régulière de fetchmail et procmail avec cron

crontab -e 

--------------------------------------------------
*/10 * * * * /usr/bin/fetchmail -m /usr/bin/procmail >> /home/fred/.fetchlog 2>&1

Lancement toute les 10 mns

Filtrage des mails 

Spamassassin + pyzor + razor

Apprentissage : sa-learn --spam --dir /home/fred/Mail/spam/new

~/.spamassassin$ vim  user_prefs

#spamAssassin config file for version 2.5x
# generated by http://www.yrex.com/spam/spamconfig.php (version 1.01)

# How many hits before a message is considered spam.

# Whether to change the subject of suspected spam
rewrite_subject         1

# Text to prepend to subject if rewrite_subject is used
subject_tag             *****SPAM*****

# Encapsulate spam in an attachment
report_safe             1

# Use terse version of the spam report
use_terse_report        0

# Enable the Bayes system
use_bayes               1

# Enable Bayes auto-learning
auto_learn              1

# Enable or disable network checks
use_razor2              1
use_dcc                 1
use_pyzor               1

# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
# - french
ok_languages fr

blacklist_from *@microsoft.com
whitelist_to *@CULTe.org
whitelist_to *@lists.debian.org
blacklist_from friend@somewhere.com
blacklist_from *@isp.com
blacklist_from someone@somewhere.com

dns_available yes
Edition des mails avec MUTT

 http://www.muttfr.org/

Sébastien MICHEL: http://michoux.born2frag.org/config/muttrc.html

Envoi des mails avec exim 

eximconf + section rewrite 

######################################################################
#                      REWRITE CONFIGURATION                         #
######################################################################

*@localhost ${lookup{$1}lsearch{/etc/email-addresses}\
{$value}fail} frFs

#*@fred ${lookup{$1}lsearch{/etc/email-addresses}\
*@fred1.fred ${lookup{$1}lsearch{/etc/email-addresses}\
{$value}fail} frFs

f1sxo@ref-union.org     fred@localhost, bctT
zulian@free.fr          fred@localhost, bctT
zulian@zulian.com       fred@localhost, bctT