Maildrop : Différence entre versions
(→Postfix) |
(→Configuration avancée) |
||
(17 révisions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
+ | {{Serveur de Messagerie}} | ||
+ | |||
+ | __TOC__ | ||
+ | |||
+ | == Prérequis == | ||
+ | |||
+ | Disposer d'un serveur mail '''Postfix''' fonctionnant avec des utilisateurs virtuels ''(c.f [[Postfix_Mysql]])'' | ||
+ | |||
+ | == Présentation == | ||
+ | |||
+ | '''Maildrop''' est un '''MDA''' ''(Mail Delivery Agent)'', programme qui permet de recevoir, filtrer et délivrer les messages dans les boîtes mails des utilisateurs. | ||
+ | |||
== Installation == | == Installation == | ||
− | * On installe le service maildrop : | + | * On installe le service '''maildrop''' : |
{{ Box Console | objet=sudo apt-get install maildrop }} | {{ Box Console | objet=sudo apt-get install maildrop }} | ||
Ligne 26 : | Ligne 38 : | ||
maildrop unix - n n - - pipe | maildrop unix - n n - - pipe | ||
− | flags=DRhu user=vmail:vmail argv=/usr/bin/maildrop -w 90 -d ${user}@${nexthop} ${extension} ${recipient} ${user} {nexthop} | + | flags=DRhu user=vmail:vmail argv=/usr/bin/maildrop -w 90 -d ${user}@${nexthop} ${extension} ${recipient} ${user} ${nexthop} ${sender} |
=== Maildrop === | === Maildrop === | ||
Ligne 35 : | Ligne 47 : | ||
DEFAULT="/var/mail/vmail/" | DEFAULT="/var/mail/vmail/" | ||
+ | |||
+ | {{ Box Remarque | objet=Le chemin <font color=grey>/var/mail/vmail/</font> définit le répertoire où sont stockés les boîtes mails des utilisateurs. }} | ||
* Les règles de routage des mails sont écrites dans le fichier '''/var/mail/vmail/.mailfilter''' : | * Les règles de routage des mails sont écrites dans le fichier '''/var/mail/vmail/.mailfilter''' : | ||
USER_DIR="/var/mail/vmail/$4/$3/" | USER_DIR="/var/mail/vmail/$4/$3/" | ||
− | to USER_DIR | + | to $USER_DIR |
− | + | ||
+ | * On applique les permissions adéquates sur les fichiers utilisés par '''maildrop''' : | ||
+ | |||
+ | {{ Box Console | objet=chown vmail:daemon /etc/maildroprc<br /> | ||
+ | chown vmail:daemon /var/run/courier/authdaemon/ -R<br /> | ||
+ | chown vmail:vmail /var/mail/vmail/.mailfilter }} | ||
+ | |||
== Configuration avancée == | == Configuration avancée == | ||
− | * | + | * Voici un exemple de script utilisé qui permet - en plus de délivrer les mails dans la boîte de l'utilisateur - de créer la boîte mail si elle n'existe pas ''(nouvel utilisateur virtuel)'', rediriger les mails tagués comme '''spam''' dans le dossier correspondant ''(par défaut Junk)''. |
# Global maildrop filter file (used on Debian) | # Global maildrop filter file (used on Debian) | ||
Ligne 69 : | Ligne 89 : | ||
HOME_DIR="/var/mail/vmail" | HOME_DIR="/var/mail/vmail" | ||
EXTENSION="$1" | EXTENSION="$1" | ||
+ | logfile "/var/log/maildroprc.log" | ||
RECIPIENT=tolower("$2") | RECIPIENT=tolower("$2") | ||
USER="$3" | USER="$3" | ||
Ligne 120 : | Ligne 141 : | ||
} | } | ||
− | * | + | * Pour que le script puisse fonctionner, vous devez au préalable créer le fichier de log '''maildroprc.log''' à la racine '''/var/log''' : |
− | {{ Box Console | objet=chown vmail: | + | {{ Box Console | objet=cd /var/log<br /> |
− | + | sudo touch maildroprc.log<br /> | |
− | + | sudo chown vmail:vmail maildroprc.log }} | |
+ | |||
+ | == Debug == | ||
+ | |||
+ | === Informations sur la version courante === | ||
+ | |||
+ | {{ Box Console | objet=/usr/bin/maildrop -v<br /> | ||
+ | maildrop 2.5.5 Copyright 1998-2005 Double Precision, Inc.<br /> | ||
+ | GDBM/DB extensions enabled.<br /> | ||
+ | Dovecot Authentication extension enabled.<br /> | ||
+ | Courier Authentication Library extension enabled.<br /> | ||
+ | Maildir quota extension are now always enabled.<br /> | ||
+ | This program is distributed under the terms of the GNU General Public<br /> | ||
+ | License. See COPYING for additional information. | ||
+ | }} | ||
+ | |||
+ | === Caractéristiques d'un compte mail === | ||
+ | |||
+ | {{ Box Console | objet=authtest cacheln@geocoucou.eu<br /> | ||
+ | Authentication succeeded.<br /><br /> | ||
+ | Authenticated: cacheln@geocoucou.eu (uid 5000, gid 5000)<br /> | ||
+ | Home Directory: /var/mail/vmail/<br /> | ||
+ | Maildir: /var/mail/vmail/geocoucou.eu/cacheln/<br /> | ||
+ | Quota: 1024<br /> | ||
+ | Encrypted Password: aBmTwv3XZeUY6<br /> | ||
+ | Cleartext Password: (none)<br /> | ||
+ | Options: disableimap=0,disablepop3=1,disablewebmail=0,sharedgroup=0 | ||
+ | }} | ||
+ | |||
+ | {{ Box Console | objet=/usr/bin/maildrop -V 7 -d cacheln@geocoucou.eu<br /> | ||
+ | maildrop: authlib: groupid=5000<br /> | ||
+ | maildrop: authlib: userid=5000<br /> | ||
+ | maildrop: authlib: logname=cacheln@geocoucou.eu, home=/var/mail/vmail/,<br /> mail=/var/mail/vmail/geocoucou.eu/cacheln/<br /> | ||
+ | maildrop: Changing to /var/mail/vmail/ | ||
+ | }} | ||
+ | |||
+ | [[Category:Serveur de Messagerie]] |
Version actuelle en date du 10 mars 2015 à 14:30
.:[ Serveur de Messagerie ]:.
Anti-Spam SpamAssassin | Anti-Virus Clamav
Plateforme de filtrage Amavis >> Amavis avec MySQL
Configurer Thundirbird | Configurer Roundcube
Commandes messagerie | DNSBL | MX Backup
Sommaire
Prérequis
Disposer d'un serveur mail Postfix fonctionnant avec des utilisateurs virtuels (c.f Postfix_Mysql)
Présentation
Maildrop est un MDA (Mail Delivery Agent), programme qui permet de recevoir, filtrer et délivrer les messages dans les boîtes mails des utilisateurs.
Installation
- On installe le service maildrop :
|
Configuration
Postfix
- On édite le fichier /etc/postfix/main.cf et on remplace :
virtual_transport = virtual
- Par :
virtual_transport = maildrop maildrop_destination_recipient_limit = 1
- Dans le fichier /etc/postfix/master.cf on remplacera :
maildrop unix - n n - - pipe flags=DRhu user=vmail:vmail argv=/usr/bin/maildrop -d ${recipient}
- Par :
maildrop unix - n n - - pipe flags=DRhu user=vmail:vmail argv=/usr/bin/maildrop -w 90 -d ${user}@${nexthop} ${extension} ${recipient} ${user} ${nexthop} ${sender}
Maildrop
- Il s'agit d'indiquer à Maildrop comment traiter les messages qui lui sont soumis par Postfix. Le but est ici d'indiquer où sont stocké les mails de nos utilisateurs.
- On crée le fichier de configuration /etc/maildroprc et on y ajoute la ligne suivante :
DEFAULT="/var/mail/vmail/"
Le chemin /var/mail/vmail/ définit le répertoire où sont stockés les boîtes mails des utilisateurs. |
- Les règles de routage des mails sont écrites dans le fichier /var/mail/vmail/.mailfilter :
USER_DIR="/var/mail/vmail/$4/$3/" to $USER_DIR
- On applique les permissions adéquates sur les fichiers utilisés par maildrop :
|
Configuration avancée
- Voici un exemple de script utilisé qui permet - en plus de délivrer les mails dans la boîte de l'utilisateur - de créer la boîte mail si elle n'existe pas (nouvel utilisateur virtuel), rediriger les mails tagués comme spam dans le dossier correspondant (par défaut Junk).
# Global maildrop filter file (used on Debian) # For use with Postfix/Courier IMAP/Amavisd-new virtual mailbox domains. # # This maildroprc automagically creates a Spam folder for the recipient # and places spam there. It also subscibes the recipient to the folder. # # Example maildir: /home/vmail/example.com/user/ # # Also in main.cf: # virtual_transport = maildrop # maildrop_destination_concurrency_limit = 2 # maildrop_destination_recipient_limit = 1 # # and in master.cf: # # maildrop unix - n n - - pipe # flags=DRhu user=vmail:vmail argv=/usr/bin/maildrop -w 90 -d ${user}@${nexthop} # ${extension} ${recipient} ${user} ${nexthop} # # /var/log/maildroprc.log needs to exist and owned by vmail:vmail and # a logrotate script needs to be created. # HOME_DIR="/var/mail/vmail" EXTENSION="$1" logfile "/var/log/maildroprc.log" RECIPIENT=tolower("$2") USER="$3" HOST="$4" SENDER="$5" DEFAULT="$HOME_DIR/$HOST/$USER" # Check if host and user directory exist `test -e $HOME_DIR/$HOST/$USER` #log "Testing for $HOME_DIR/$HOST subdirectory: result=$RETURNCODE" # Only continue if directory does NOT exist if ($RETURNCODE != 0) { log "MailDir $HOME_DIR/$HOST/$USER does NOT exist" `test -e $HOME_DIR/$HOST` if ( $RETURNCODE != 0 ) { log "Creating $HOME_DIR/$HOST" `mkdir $HOME_DIR/$HOST` `chmod -R 0700 $HOME_DIR/$HOST` } # Create users MailDir `maildirmake $HOME_DIR/$HOST/$USER` } if (/^X-Spam-Flag: YES/) { EXTENSION = "Junk" # See if the spam directory already exists `test -e $HOME_DIR/$HOST/$USER/.$EXTENSION` #log "Testing for $EXTENSION subdirectory: result=$RETURNCODE" if ( $RETURNCODE != 0 ) # spam directory does not exist - so we create it { # Create the subdirectory `maildirmake -f $EXTENSION $HOME_DIR/$HOST/$USER` log "Ran \"maildirmake -f $EXTENSION $HOME_DIR/$HOST/$USER\"" # Auto-subscribe the subdirectory `if ! grep -q INBOX.$EXTENSION $HOME_DIR/$HOST/$USER/courierimapsubscribed; then echo INBOX.$EXTENSION >> $HOME_DIR/$HOST/$USER/courierimapsubscribed; fi` } # Deliver the message to the mailbox exception { # for those who unsubscribed themselves - subscribe them `if ! grep -q INBOX.$EXTENSION $HOME_DIR/$HOST/$USER/courierimapsubscribed; then echo INBOX.$EXTENSION >> $HOME_DIR/$HOST/$USER/courierimapsubscribed; fi` to "$HOME_DIR/$HOST/$USER/.$EXTENSION" } }
- Pour que le script puisse fonctionner, vous devez au préalable créer le fichier de log maildroprc.log à la racine /var/log :
|
Debug
Informations sur la version courante
|
Caractéristiques d'un compte mail
|
|