Extrait d'un ancien post (page retirée):
Une solution (pour Debian mais facilement utilisable ailleurs, et directement sous Ubuntu) qui ne demande qu'à être améliorée/corrigée :) (votre machine s'appelle machine.mondomaine.net, votre utilisateur s'appelle toto, votre mail est toto@mondomaine.net, géré ailleurs bien sûr) :
-
installez postfix :
sudo apt-get install postfix
-
répondez « No configuration » (« Pas de configuration »)
-
copiez le squelette de configuration :
sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf
-
on va éditer ce fichier de config et y mettre les paramètres que l'on veut (voir le fichier détaillé plus bas) :
sudo nano /etc/postfix/main.cf
-
on va rajouter des alias locaux utiles :
sudo nano /etc/aliases
il doit déjà y avoir les deux lignes suivantes :
# Added by installer for initial user
root: toto
ajoutez :
postmaster: toto
toto: toto@mondomaine.net
-
régénérez les alias :
sudo newaliases
-
éditez
/etc/mailname
: ce fichier doit contenir une seule ligne avec votre nom de machine (dans notre exemple, machine.mondomaine.net) -
et c'est parti :
sudo /etc/init.d/postfix restart
—
Fichier main.cf : (Je n'ai pas trouvé comment faire garder les tabulations à DokuWiki, donc les deux lignes vers la fin où vous pouvez lire TABULATION, remplacez ce mot par une tabulation)
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
append_at_myorigin = yes
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
myhostname = machine.mondomaine.net
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydomain = mondomaine.net
mydestination = $myhostname, localhost.$mydomain, localhost
relayhost =
mynetworks = 127.0.0.0/8
luser_relay = toto@mondomaine.net
smtpd_client_restrictions =
TABULATIONpermit_mynetworks
TABULATIONreject
disable_vrfy_command = yes
empty_address_recipient = toto@mondomaine.net
Voir aussi : http://x.guimard.free.fr/postfix/
Sécurisation
voir :
https://www.isalo.org/wiki.debian-fr/Configuration_d'un_serveur_mail_avec_Postfix
https://www.howtoforge.com/virtual_postfix_antispam
http://blog.admin-linux.org/administration/analyser-les-logs-de-son-serveur-mails-postfix
https://www.spamcop.net/fom-serve/cache/349.html