Install Postfix server with SASL

Wikis > Informatique > Linux > Postfix > Install Postfix server with SASL

== Introduction ==

Nous allons voir comment installer le serveur mail Postfix avec authentification SASL.

Il est extrêmement facile d’installer et de configurer Postfix en serveur de mail.

== Installation de Postfix et saslauth ==

aptitude install postfix postfix-doc libsasl2-modules sasl2-bin

Quelques questions vous sont posées :

Type de configuration : internet
Destinataire du courrier destiné au superutilisateur : root
Nom de courrier : dom-sln.local
Autres destinations pour lesquelles le courrier sera accepté (champ vide autorisé) : dom-sln.local, localhost, localhost.localdomain, localhost
Faut-il forcer des mises à jour synchronisées de la file d’attente des courriels ? non
Réseaux internes : 127.0.0.0/8, 10.1.1.0/24, 10.3.1.0/24, 10.1.1.254
Faut-il utiliser procmail pour la distribution locale ? non
… La suite par défaut convient parfaitement.

== Configuration de saslauthd ==

*/etc/default/saslauthd

START=yes
MECHANISMS="pam"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r -V"

!!! C’est excessivement important !!!
Vous devez déplacer le socket de saslauthd dans le « chroot » de postfix !

mkdir --parents --mode=755 /var/spool/postfix/var/run
mv /var/run/saslauthd /var/spool/postfix/var/run/saslauthd
ln --symbolic /var/spool/postfix/var/run/saslauthd /var/run/saslauthd
chown root:sasl /var/run/saslauthd

== Configuration de Postfix ==

*/etc/postfix/main.cf

# 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

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = languille11.fr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = languille11.fr
relayhost =
mynetworks = 127.0.0.0/8, 10.1.1.0/24, 10.3.1.0/24, 10.1.1.254
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4

# Setting up SMTP authentication.
smtpd_sasl_auth_enable = yes
smtpd_tls_auth_only = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination

Créez le fichier /etc/postfix/sasl/smtpd.conf avec les droits 644 pour (root:postfix) contenant :

pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level: 0

Ajoutez l’utilisateur postfix au groupe sasl

adduser postfix sasl

Redémarrez postfix

/etc/init.d/postfix restart

== Test de la configuration ==

telnet languille11.fr 25

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost ESMTP Postfix (Debian/GNU)
ehlo some.com
250-localhost
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
QUIT
221 2.0.0 Bye
Connection closed by foreign host.