Local Postfix Dovecot – Ubuntu 14.04 Trusty

Pré-requis

vi /etc/hosts

192.168.1.10    mail    mail.test.lan

apt-get update; apt-get upgrade -y
apt-get install postfix dovecot-imapd libsasl2-2 sasl2-bin libsasl2-modules -y

Demande de création du certificat autosigné oui
nom d'hôte test
Type de messagerie Site Internet
Nom de courrier test

Paramétrages

Postfix

  • On refait configuration du serveur à partir de l'utilitaire dpkg-reconfigure :

dpkg-reconfigure postfix

Nom de courrier mail
Destinataire des courriels de root toto
Autres destinations pour lesquelles… mail, localhost.localdomain, localhost, test.lan
Faut il forcer les mises à jour… non
Réseaux internes 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.0/24
Taille maximale des boites 0 (indéfinie)
Caractère d'extension des adresses +
Protocoles internet à utiliser tous
  • Création du fichier mailname :

echo "test.lan" > /etc/mailname

mv /etc/postfix/main.cf{,.ori}
vi /etc/postfix/main.cf

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no

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:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

myhostname = chronos
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = chronos test.lan
relayhost =
mynetworks = 127.0.0.0/8 192.168.1.0/24
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
home_mailbox = Maildir/

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

queue_directory = /var/spool/postfix

cp /etc/postfix/main.cf{,.ori}
vi /etc/postfix/master.cf

## Enable SMTP on port 587 only for authenticated/TLS clients
submission inet n       -       n       -       -       smtpd
  -o smtpd_enforce_tls=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

## Enable SMTP on port 465 only for authenticated/SSL clients
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

cp /etc/dovecot/dovecot.conf{,.ori}
sed -i 's/#listen/listen/g' /etc/dovecot/dovecot.conf

cp /etc/dovecot/conf.d/10-auth.conf{,.ori}
sed -i 's,#disable_plaintext_auth = yes,disable_plaintext_auth = no,g' /etc/dovecot/conf.d/10-auth.conf
sed -i 's,auth_mechanisms = plain,auth_mechanisms = plain login,g' /etc/dovecot/conf.d/10-auth.conf

/etc/dovecot/conf.d/10-mail.conf

  • Paramétrage du chemin où seront stockés les messages :

cp /etc/dovecot/conf.d/10-mail.conf{,.ori}
sed -i 's,mail_location = mbox:~/mail:INBOX=/var/mail/%u,mail_location = maildir:~/Maildir,g' /etc/dovecot/conf.d/10-mail.conf

/etc/dovecot/conf.d/10-master.conf

  • Dé-commenter et ajouter (lignes 89-93) :

cp /etc/dovecot/conf.d/10-master.conf{,.ori}
vi /etc/dovecot/conf.d/10-master.conf

service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
}

SASL

/etc/default/saslauthd

  • Pour que SASL se lance en tant que démon :

cp /etc/default/saslauthd{,.ori}
sed -i "s/START=no/START=yes/g" /etc/default/saslauthd

  • Redémarrage des services :

for serv in postfix dovecot; do /etc/init.d/$serv restart;done
tailf /var/log/mail.log