Le Forum Non Officiel de la DEDIBOX
Vous n'êtes pas identifié.
Cette documentation traite de l’installation et de la configuration de postfix pour servir plusieur domaine.
Nous allons utiliser postfix admin qui permet de simplement administrer ses domaines.
Nous configurerons rapidement un serveur IMAP afin de pouvoir accèder aux mails (saymieu !).
Comme je suis sympa, je filera une tite conf pour réduire le spam à l’aide de postfix.
Le serveur doit disposer:
Sous Débian:
# apt-get install mysql-server apache php4 postfix postfix-mysql php4-mysql
Pour les diverses configurations des pkgs, ne vous encombrez pas, nous supposons que la configuration par défaut suffira pour le moment. Néanmoins, je fournirais une configuration un peu plus fourni en fin du document pour postfix, centre de la documentation.
Vous devez disposer:

Une fois tout ce petit monde installé (apache, postfix, mysql …) nous allons mettre en place postfixadmin, que nous nommerons par la suite pfadmin pour la forme.
L’application est disponible ici: http://high5.net/postfixadmin/
Donc, rapidement:
# cd /data # mkdir -p www/mailadmin # cd www/mailadmin # wget http://high5.net/postfixadmin/download.php?file=postfixadmin-2.1.0.tgz # mv download.php?file=postfixadmin-2.1.0.tgz postfixadmin-2.1.0.tgz # tar zxsf postfixadmin-2.1.0.tgz # mv postfixadmin-2.1.0/* . # rmdir postfixadmin-2.1.0 # chown -R root.root * # cp config.inc.php.sample config.inc.php
Nous allons faire un détour par MySQL pour configurer une base pour posftix:
Mais avant ca, nous allons préparer le password pour le compte mysql:
# makepasswd xr4BD3
Si vous n’avez pas makepasswd:
# apt-get install makepasswd
Maintenant, MySQL:
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 8 to server version: 5.0.22-Debian_3-log Type 'help;' or 'h' for help. Type 'c' to clear the buffer. mysql>
La c’est tres facile, nous allons créer une base et ajouter une utilisateur:
mysql> create database postfix; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on postfix.* to 'postfix'@'localhost' identified by 'xr4BD3' with grant option; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
Un petit test pour s’assurer que tout est ok:
# mysql -u postfix -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 10 to server version: 5.0.22-Debian_3-log Type 'help;' or 'h' for help. Type 'c' to clear the buffer. mysql>
Maintenant nous devons créer les tables de pfadmin, mais avant de soumettre le script sql, éditez le fichier, et commentez les lignes suivantes (celles de création de la table) du fichier DATABASE_MYSQL.TXT:
#USE postfix;
# Postfix user & password
#INSERT INTO user (Host, User, Password) VALUES ('localhost','postfix',password('postfix'));
#INSERT INTO db (Host, Db, User, Select_priv) VALUES ('localhost','postfix','postfix','Y');
# Postfix Admin user & password
#INSERT INTO user (Host, User, Password) VALUES ('localhost','postfixadmin',password('postfixadmin'));
#INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('localhost', 'postfix', 'postfixadmin', 'Y', 'Y', #'Y', 'Y');
#FLUSH PRIVILEGES;
#GRANT USAGE ON postfix.* TO postfix@localhost;
#GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfix@localhost;
#GRANT USAGE ON postfix.* TO postfixadmin@localhost;
#GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfixadmin@localhost;
#CREATE DATABASE postfix;
Une fois que vous avez bien commentez ces lignes:
#cat DATABASE_MYSQL.TXT | mysql -u postfix -p Enter password:
Revenons à la configuration de pfadmin:
# vi config.inc.php
Modifiez les valeurs suivantes:
$CONF['postfix_admin_url'] = 'mailadmin.domaine.tld';
$CONF['postfix_admin_path'] = '/data/www/mailadmin';
$CONF['database_type'] = 'mysqli'; // LIRE LA NOTE !!
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'xr4BD3';
$CONF['database_name'] = 'postfix';
$CONF['database_prefix'] = '';
$CONF['admin_email'] = 'VOTRE MAIL';
$CONF['default_aliases'] = array (
'abuse' => 'abused@domaine.tld',
'hostmaster' => 'hostmaster@domaine.tld',
'postmaster' => 'postmaster@domaine.tld',
'webmaster' => 'webmaster@domaine.tld'
);
$CONF['domain_path'] = 'YES';
$CONF['alias_control'] = 'YES';
NOTE:
Utilisez ’mysql’ dans le cas de mysql 3.X ou 4.0 sinon gardez ’mysqli’ pour mysql 4.1 et 5.X MAIS C’EST LA THEORIE. En général, mysql … suffit …
Il a d’autres petites configs a faire, prennez le temps de regarder, mes voici les plus importantes.
Petite touche de sécurité, pensez à modifier les droits sur le config.inc.php, le password mysql étant en clair:
# chmod 640 config.inc.php
Et pour faire les choses plus propres, vous pouvez passer tous vos fichiers en 640:
# chmod 640 *.php *.css # cd admin # chmod 640 *.php .ht* # cd ../images # chmod 640 *.php *.png *.xcf # cd ../languages # chmod 640 *.lang *.php # cd ../templates # chmod 640 *.tpl *.php # cd ../users # chmod 640 *.php # cd ..
Il ne manque plus que de mettre le bon groupe pour le fichiers, dans mon cas, apache tourne sous l’utilisateur www-data (défaut dans debian):
# chgrp -R www-data *
Configurons apache pour pouvoir accèder à pfadmin, la version utilisée est une 1.3. Rajouteons un vhost, comme par exemple mailadmin.domaine.tld (remplacez domaine.tld par votre domaine …):
# vi /etc/apache/conf.d/vhosts
Et ajoutez les lignes suivantes:
<VirtualHost *:80>
ServerAdmin postmaster@domaine.tld
DocumentRoot /data/www/mailadmin
ServerName mailadmin.domaine.tld
</VirtualHost>
Configuration tres tres simpliste. Je vous invite à la paufiner pour votre utilisation (logs …). Une fois la configuration ajoutée:
# apachectl configtest Syntax OK # /etc/init.d/apache restart Restarting apache 1.3 web server....
Si les DNS sont bien configurés, vous pouvez accèder à l’interface de pfadmin.
Pensez à supprimer le fichier setup.php une fois l’installation effectuée !
Pour l’interface d’admin générale, tappez /admin.
Pensez à protéger cette derniere par un htaccess !!!
Nous allons configurer Postfix pour qu’il utilise les tables de postfix admin pour délivrer son courier, rien de plus simple.
Nous allons tout dabord utiliser une fonctionnalité bien sympa de postfix, les variables:
(indiquer quel fichier, peut etre, non ? (/etc/postfix/main.cf ??)) -pi-xel
# [mysql infos] mysql_user = postfix mysql_passwd = xr4BD3 mysql_host = localhost mysql_dbname = postfix
Ensuite, nous allons dire à Postfix où il doit aller chercher les informations:
# [mysql_relay_domains_maps] relay_domains_maps_user = $mysql_user relay_domains_maps_password = $mysql_passwd relay_domains_maps_hosts = $mysql_host relay_domains_maps_dbname = $mysql_dbname relay_domains_maps_table = domain relay_domains_maps_select_field = domain relay_domains_maps_where_field = domain # [mysql_virtual_alias_maps] alias_maps_user = $mysql_user alias_maps_password = $mysql_passwd alias_maps_hosts = $mysql_host alias_maps_dbname = $mysql_dbname alias_maps_table = alias alias_maps_select_field = goto alias_maps_where_field = address # [mysql_virtual_domains_maps] domains_maps_user = $mysql_user domains_maps_password = $mysql_passwd domains_maps_hosts = $mysql_host domains_maps_dbname = $mysql_dbname domains_maps_table = domain domains_maps_select_field = description domains_maps_where_field = domain # [mysql_virtual_mailbox_limit_maps] mailbox_limit_maps_user = $mysql_user mailbox_limit_maps_password = $mysql_passwd mailbox_limit_maps_hosts = $mysql_host mailbox_limit_maps_dbname = $mysql_dbname mailbox_limit_maps_table = mailbox mailbox_limit_maps_select_field = quota mailbox_limit_maps_where_field = username # [mysql_virtual_mailbox_maps] mailbox_maps_user = $mysql_user mailbox_maps_password = $mysql_passwd mailbox_maps_hosts = $mysql_host mailbox_maps_dbname = $mysql_dbname mailbox_maps_table = mailbox mailbox_maps_select_field = maildir mailbox_maps_where_field = username
Sans oublier:
virtual_alias_maps = mysql:alias_maps virtual_uid_maps = static:101 virtual_gid_maps = static:104 virtual_mailbox_base = /data/mail virtual_mailbox_domains = mysql:domains_maps virtual_mailbox_limit = 204800000 virtual_mailbox_maps = mysql:mailbox_maps virtual_minimum_uid = 100 virtual_transport = virtual # Additional for quota support virtual_create_maildirsize = yes virtual_mailbox_extended = yes virtual_mailbox_limit_maps = mysql:mailbox_limit_maps virtual_mailbox_limit_override = yes virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later. virtual_overquota_bounce = yes
Je vous invite à personnaliser les parametres !
Pour voir ce que donne mon fichier de conf postfix à la fin:
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no append_dot_mydomain = no myhostname = xxxxxx.domaine.tld alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = xxxxxx , xxxxxx.domaine.tld , localhost.localdomain , localhost relayhost = mynetworks = 127.0.0.0/8 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all virtual_alias_maps = mysql:alias_maps virtual_uid_maps = static:101 virtual_gid_maps = static:104 virtual_mailbox_base = /data/mail virtual_mailbox_domains = mysql:domains_maps virtual_mailbox_limit = 204800000 virtual_mailbox_maps = mysql:mailbox_maps virtual_minimum_uid = 100 virtual_transport = virtual # Additional for quota support virtual_create_maildirsize = yes virtual_mailbox_extended = yes virtual_mailbox_limit_maps = mysql:mailbox_limit_maps virtual_mailbox_limit_override = yes virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later. virtual_overquota_bounce = yes # [mysql infos] mysql_user = postfix mysql_passwd = xr4BD3 mysql_host = localhost mysql_dbname = postfix # [mysql_relay_domains_maps] relay_domains_maps_user = $mysql_user relay_domains_maps_password = $mysql_passwd relay_domains_maps_hosts = $mysql_host relay_domains_maps_dbname = $mysql_dbname relay_domains_maps_table = domain relay_domains_maps_select_field = domain relay_domains_maps_where_field = domain # [mysql_virtual_alias_maps] alias_maps_user = $mysql_user alias_maps_password = $mysql_passwd alias_maps_hosts = $mysql_host alias_maps_dbname = $mysql_dbname alias_maps_table = alias alias_maps_select_field = goto alias_maps_where_field = address # [mysql_virtual_domains_maps] domains_maps_user = $mysql_user domains_maps_password = $mysql_passwd domains_maps_hosts = $mysql_host domains_maps_dbname = $mysql_dbname domains_maps_table = domain domains_maps_select_field = domain domains_maps_where_field = domain # [mysql_virtual_mailbox_limit_maps] mailbox_limit_maps_user = $mysql_user mailbox_limit_maps_password = $mysql_passwd mailbox_limit_maps_hosts = $mysql_host mailbox_limit_maps_dbname = $mysql_dbname mailbox_limit_maps_table = mailbox mailbox_limit_maps_select_field = quota mailbox_limit_maps_where_field = username # [mysql_virtual_mailbox_maps] mailbox_maps_user = $mysql_user mailbox_maps_password = $mysql_passwd mailbox_maps_hosts = $mysql_host mailbox_maps_dbname = $mysql_dbname mailbox_maps_table = mailbox mailbox_maps_select_field = maildir mailbox_maps_where_field = username
Pensez à modifier les valeurs en fonction de votre machine !
Il y a encore une derniere chose à modifier dans postfix.
Editez le fichier master.cf et changez les valeurs du chroot en “n”, comme ci-dessous:
smtp inet n - n - - smtpd
pickup fifo n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr fifo n - n 300 1 qmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
-o fallback_relay=
showq unix n - n - - showq
error unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
Si vous souhaite quand meme chrooté ces programmes, il existe un moyen en déplacant la socket mysql. Vous trouverez tout ce qu’il faut sur google.fr
Nous allons à l’essentiel dans cette documentation (et disons le, c’est pas non plus la mort de pas les avoir en chroot …)
Sauvegardez et rechargez postfix !
# /etc/init.d/postfix restart
Vous pouvez tester rapidement votre configuration. Il suffit d’ajouter un domaine à l’aide de pfadmin, d’un ajouter un compte.
Ensuite, un coup de telnet:
Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. 220 xxx.domaine.tld ESMTP Postfix (Debian/GNU) helo chninkel.net 250 xxx.domaine.tld mail from: xxx@domaine.tld 250 Ok rcpt to: test@test.com 250 Ok data 354 End data with <CR><LF>.<CR><LF> TEST TEST TEST TEST TEST . 250 Ok: queued as B69AEC050 ^] telnet> Connection closed.
Et si vous allez voir dans le repertoire de stockage des mails, vous devriez trouver votre message.
Bon c’est pas tout cela mais il faudrait quand mème pouvoir consulter ses mails …
C’est là qu’intervient courier-imap
il peut fonctionner tant en imap qu’en pop , il suffit d’installer ce que l’on désire . Le plus simple est donc un :
aptitude install courier-pop courier-authmysql courier-imap courier-authdaemon
ceci étant fait la configuration se déroule dans /etc/courier/
Dans le fichier /etc/courier/authdaemonrc il faut s’assurer que l’auth mysql est prise en compte :
authmodulelist=”authpam authmysql”
Au niveau du fichier /etc/courier/authmysqlrc,nous allons pouvoir configurer le nécessaire pour que courier puisse trouver les informations nécessaires à l’acces aux mails.
Il n’y normalement rien a changer pour les fichiers /etc/courier/imapd & /etc/courier/pop3d.
Pour mémoire le login par pop/imap est du style loginutilisateur@domainevirtuel.tld , et non pas juste loginutilisateur.
Partie copié directement depuis » http://www.littleboboy.net/postfix-mysql-courier-imap/
TODO !