Ce tutoriel explique comment mettre en place un serveur de mail sous Debian avec Postfix et Courier-imap / Courier-pop avec l’ajout du webmail Squirrelmail et le gestionnaire de liste de diffusion Mailman
aptitude update
aptitude install postfix courier-imap courier-pop3 mailman
Après les demandes de l’installeur de postfix, votre fichier /etc/postfix/main.cf devrait ressembler à ceci :
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
myhostname = monsite.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = monsite.com
relayhost =
mynetworks = 127.0.0.0/8, monsite.com
mailbox_command =
mailbox_size_limit = 51200000
recipient_delimiter = +
La variable mynetworks ainsi positionnée ne permet alors un envoi de mail que depuis la machine locale et évite ainsi que votre machine soit un “open relay.”
Dans /etc/postfix/main.cf, il faut ajouter la ligne :
home_mailbox = Maildir/
Vous avez ainsi :
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
myhostname = monsite.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = monsite.com
relayhost =
mynetworks = 127.0.0.0/8, monsite.com
# mailbox_command =
mailbox_size_limit = 51200000
recipient_delimiter = +
# Envoi dans Courier
home_mailbox = Maildir/
Pour chacun de vos utilisateur systèmes, il vous faut alors créer un dossier Maildir qui se fait via la commande :
maildirmake /home/utilisateur/Maildir</code>
Attention à bien positionner les droits et les appartenances (ce doit être ceux de l’utilisateur et non root...)
chmod 777 -R /home/utilisateur/Maildir
chown utilisateur: -R /home/utilisateur/Maildir
Relancez alors Postfix :
/etc/init.d/postfix restart ou reload
Envoyez un mail à l’un de vos utilisateurs.
Dans /home/utilisateur/Maildir/new vous devez voir apparaitre un fichier qui n’est autre que votre mail (un coup de less vous le confirmera)
tar xzf fichier.tar.gz
tar xjf fichier.tar.bz2
mv squirrelmail-version webmail
mv webmail /var/www/
chmod 777 /var/www/webmail/data/
Mailman est un gestionnaire de listes de diffusion assez puissant et relativement simple à utiliser.
Les listes ici seront de la forme liste@monsite.com
Je me base essentiellement sur la doc présente dans /usr/share/doc/mailman/README.Posftix et autres éléments trouvés sur internet.
MTA = ’Postfix’
-rw-rw---- 1 root list 3419 2005-01-26 12:49 aliases
-rw-r--r-- 1 root list 49152 2005-01-26 12:49 aliases.db
Il faut donc faire et contrairement à la doc : * ne pas changer l’appartenance des fichiers aliases à list:daemon - on laisse root:list * chmod 666 aliases*, sinon mailman refusait de me créer mes listes :-( * Dans /etc/postfix/main.cf, il vous faut ajouter les informations suivantes :
unknown_local_recipient_reject_code = 550
# Gestion de mailman => ajout de hash:/var/lib/mailman/data/aliases
alias_maps = hash:/etc/postfix/aliases, hash:/var/lib/mailman/data/aliases
newlist mailman
ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/
Alias /pipermail/ /var/lib/mailman/archives/public/
<Directory /usr/lib/cgi-bin/mailman/>
AllowOverride All
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
et relancez Apache pour que la modification soit prise en compte.
/etc/init.d/apache2 reload
mmsitepass nouveaumotdepasse
Au final, vous avez le fichier mailman suivant : /etc/mailman/mm_cfg.py
#######################################################
# Here's where we get the distributed defaults. #
from Defaults import *
##############################################################
# Put YOUR site-specific configuration below, in mm_cfg.py . #
# See Defaults.py for explanations of the values. #
#-------------------------------------------------------------
# The name of the list Mailman uses to send password reminders
# and similar. Don't change if you want mailman-owner to be
# a valid local part.
MAILMAN_SITE_LIST = 'mailman'
#-------------------------------------------------------------
# If you change these, you have to configure your http server
# accordingly (Alias and ScriptAlias directives in most httpds)
# Pour que vos listes soient accessibles sous la forme http://www.monsite.com/mailman/
DEFAULT_URL_PATTERN = 'http://%s/mailman/'
PRIVATE_ARCHIVE_URL = '/mailman/private'
IMAGE_LOGOS = '/images/mailman/'
#-------------------------------------------------------------
# Default domain for email addresses of newly created MLs
DEFAULT_EMAIL_HOST = 'monsite.com'
#-------------------------------------------------------------
# Default host for web interface of newly created MLs
DEFAULT_URL_HOST = 'monsite.com'
#-------------------------------------------------------------
# Required when setting any of its arguments.
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
#-------------------------------------------------------------
# The default language for this server.
# Pour la prise en compte du français
DEFAULT_SERVER_LANGUAGE = 'fr'
#-------------------------------------------------------------
# Iirc this was used in pre 2.1, leave it for now
USE_ENVELOPE_SENDER = 0 # Still used?
#-------------------------------------------------------------
# Unset send_reminders on newly created lists
DEFAULT_SEND_REMINDERS = 0
#-------------------------------------------------------------
# Uncomment this if you configured your MTA such that it
# automatically recognizes newly created lists.
# (see /usr/share/doc/mailman/README.{EXIM,...})
# MTA=None # Misnomer, suppresses alias output on newlist
#-------------------------------------------------------------
# Uncomment if you use Postfix virtual domains, but be sure to
# read /usr/share/doc/mailman/README.POSTFIX first.
MTA='Postfix'
# Note - if you're looking for something that is imported from mm_cfg, but you
# didn't find it above, it's probably in /usr/lib/mailman/Mailman/Defaults.py.</code>
Votre fichier /etc/postfix/main.cf :
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
delay_warning_time = 4h
myhostname = monsite.com
alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = monsite.com
relayhost =
mynetworks = 127.0.0.0/8, monsite.com
# mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
# Envoi dans Courier
home_mailbox = Maildir/
# Ajout de mailman
unknown_local_recipient_reject_code = 550