Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
dbmail [Le 23/07/2013, 18:33] – [PostFix] paquets titouan | dbmail [Le 28/06/2014, 14:14] (Version actuelle) – Plainte de l'adresse utilisée comme exemple (pierre.durand@) xabilon | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | {{tag> | ||
+ | ---- | ||
+ | ====== DBMail : serveur de courrier IMAP et POP ====== | ||
+ | |||
+ | **DBMail** permet de stocker les courriels dans une base de données au lieu du disque, et d'y accéder en IMAP ou POP. | ||
+ | |||
+ | Il travaille en conjonction avec [[Postfix]], | ||
+ | |||
+ | ===== Pré-requis ===== | ||
+ | * Disposer d'un Nom de Domaine Déposé auprès d'un Registrar et d'un enregistrement MX. | ||
+ | < | ||
+ | * Expérience vivement recommandée en LAMP et SSH, pour une meilleure méthodologie et débogage | ||
+ | * Cas particuliers auto-hébergement | ||
+ | |||
+ | ^ | ||
+ | ^ Cas ^ IP fixe ^dynamique | ||
+ | ^1 | ||
+ | ^2 | ||
+ | ^3 | ||
+ | ^4 | ||
+ | ^4 | --------------------> | ||
+ | ^5 | x | ||
+ | ^6 | | | ||
+ | légende; | ||
+ | >Cas 1,2,3 recommandés | ||
+ | |||
+ | ===== PostFix ===== | ||
+ | * paquets | ||
+ | < | ||
+ | sudo apt-get install postfix postfix-cdb postfix-mysql postfix-pcre postfix-ldap postfix-doc pflogsumm | ||
+ | sudo apt-get install libgsasl7 libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin cyrus-sasl2-dbg cyrus-sasl2-doc | ||
+ | sudo apt-get install php-auth-sasl php5-sasl libapache2-mod-authn-sasl | ||
+ | </ | ||
+ | |||
+ | === Configuration de postfix === | ||
+ | < | ||
+ | sudo dpkg-reconfigure postfix | ||
+ | </ | ||
+ | * Ajouter à la fin de sudo nano / | ||
+ | < | ||
+ | dbmail-lmtp | ||
+ | </ | ||
+ | |||
+ | === mailname main.cf === | ||
+ | |||
+ | < | ||
+ | domain.tld</ | ||
+ | |||
+ | * // | ||
+ | *// smtp.domain.tld// | ||
+ | * le mailto: // | ||
+ | NB: valable également pour un // | ||
+ | * /etc/hosts | ||
+ | < | ||
+ | 127.0.0.1 | ||
+ | # | ||
+ | # The following lines are desirable for IPv6 capable hosts | ||
+ | ::1 | ||
+ | fe00::0 ip6-localnet | ||
+ | ff00::0 ip6-mcastprefix | ||
+ | ff02::1 ip6-allnodes | ||
+ | ff02::2 ip6-allrouters | ||
+ | </ | ||
+ | Il n'est pas nécessaire de fixer // | ||
+ | < | ||
+ | smtp_host_lookup = native, dns | ||
+ | </ | ||
+ | * man hostname dnsdomainname | ||
+ | < | ||
+ | hostname -s # local_name | ||
+ | ce_que_vous_voulez | ||
+ | hostname -f # fqdn | ||
+ | www.mydomain.tld | ||
+ | hostname -d # domaine | ||
+ | mydomain.tld | ||
+ | </ | ||
+ | === main.cf === | ||
+ | |||
+ | * méthode //virtual// | ||
+ | sudo nano / | ||
+ | < | ||
+ | # maj 11 03 2013 | ||
+ | # Requis | ||
+ | alias_database = hash:/ | ||
+ | alias_maps = hash:/ | ||
+ | append_dot_mydomain = no | ||
+ | biff = no | ||
+ | readme_directory = no | ||
+ | config_directory = / | ||
+ | recipient_delimiter = + | ||
+ | smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) | ||
+ | receive_override_options = no_address_mappings | ||
+ | |||
+ | inet_interfaces = all | ||
+ | inet_protocols = ipv4 | ||
+ | |||
+ | myhostname = smtp.domain.tld | ||
+ | mydomain = domain.tld | ||
+ | mynetworks = 127.0.0.1 192.168.1.x 11.22.33.44 | ||
+ | myorigin = $mydomain | ||
+ | mydestination = localhost | ||
+ | relay_domains = $mydestination | ||
+ | relay_recipient_maps = mysql:/ | ||
+ | relayhost = | ||
+ | transport_maps = hash:/ | ||
+ | |||
+ | # Selon chaque config DNS | ||
+ | smtp_host_lookup = native, dns | ||
+ | smtp_cname_overrides_servername = yes | ||
+ | |||
+ | # Requis Virtual | ||
+ | virtual_mailbox_domains = mysql:/ | ||
+ | virtual_mailbox_maps = mysql:/ | ||
+ | virtual_transport = dbmail-lmtp: | ||
+ | |||
+ | # Requis SASL | ||
+ | broken_sasl_auth_clients = yes | ||
+ | smtp_sasl_auth_enable = yes | ||
+ | smtp_sasl_mechanism_filter = CRAM-MD5 PLAIN | ||
+ | smtp_sasl_password_maps = hash:/ | ||
+ | smtp_sasl_security_options = noanonymous | ||
+ | # | ||
+ | smtpd_sasl_auth_enable = yes | ||
+ | smtpd_sasl_authenticated_header = no | ||
+ | smtpd_sasl_local_domain = domain.tld list.domain.tld sous.domain.tld domain2.tld2 | ||
+ | smtpd_sasl_path = smtpd | ||
+ | smtpd_sasl_security_options = noanonymous | ||
+ | smtpd_sasl_type = cyrus | ||
+ | |||
+ | # Requis STARTTLS/ | ||
+ | smtp_tls_CAfile = /etc/...pem | ||
+ | smtp_tls_CApath = / | ||
+ | smtp_tls_cert_file = /etc/...pem | ||
+ | smtp_tls_key_file = / | ||
+ | # | ||
+ | smtp_tls_scert_verifydepth = 2 | ||
+ | smtp_tls_security_level = may | ||
+ | smtp_tls_session_cache_database = btree: | ||
+ | smtp_tls_session_cache_timeout = 900s | ||
+ | smtp_use_tls = yes | ||
+ | |||
+ | smtpd_tls_CAfile = /etc/...pem | ||
+ | smtpd_tls_CApath = / | ||
+ | smtpd_tls_ask_ccert = yes | ||
+ | smtpd_tls_auth_only = yes | ||
+ | smtpd_tls_ccert_verifydepth = 2 | ||
+ | smtpd_tls_cert_file = /etc/...pem | ||
+ | smtpd_tls_key_file = / | ||
+ | smtpd_tls_loglevel = 2 | ||
+ | smtpd_tls_mandatory_ciphers = medium | ||
+ | smtpd_tls_mandatory_protocols = TLSv1, SSLv3 | ||
+ | smtpd_tls_received_header = no | ||
+ | smtpd_tls_session_cache_database = btree: | ||
+ | smtpd_tls_session_cache_timeout = 900s | ||
+ | smtpd_use_tls = yes | ||
+ | tls_random_source = dev:/ | ||
+ | |||
+ | # Options Restrictions | ||
+ | smtpd_sender_restrictions = permit_sasl_authenticated, | ||
+ | smtpd_recipient_restrictions = permit_sasl_authenticated, | ||
+ | |||
+ | # Option x509 client | ||
+ | relay_clientcerts = hash:/ | ||
+ | |||
+ | # Option Limites | ||
+ | bounce_queue_lifetime = 36h | ||
+ | maximal_queue_lifetime = 36h | ||
+ | smtp_destination_concurrency_limit = 5 | ||
+ | smtp_destination_rate_delay = 1 | ||
+ | local_destination_concurrency_limit = 5 | ||
+ | default_destination_concurrency_limit = 10 | ||
+ | default_destination_recipient_limit = 25 | ||
+ | virtual_destination_concurrency_limit = 10 | ||
+ | virtual_destination_rate_delay = 1 | ||
+ | smtpd_client_connection_count_limit = 4 | ||
+ | smtpd_client_connection_rate_limit = 30 | ||
+ | smtpd_client_recipient_rate_limit = 30 | ||
+ | smtpd_error_sleep_time = 0 | ||
+ | smtpd_hard_error_limit = 4 | ||
+ | smtpd_recipient_limit = 30 | ||
+ | |||
+ | # Option clamsmtpd | ||
+ | content_filter = scan: | ||
+ | |||
+ | # Option dkim | ||
+ | milter_default_action = accept | ||
+ | milter_protocol = 2 | ||
+ | non_smtpd_milters = inet: | ||
+ | smtpd_milters = inet: | ||
+ | |||
+ | # Option Debogage Erreur Log | ||
+ | # sudo pflogsumm / | ||
+ | # master.cf | ||
+ | # smtp|submission|smtps | ||
+ | # smtp inet ... smtp -v | ||
+ | # postfix restart | ||
+ | # main.cf | ||
+ | # erreurs qui doivent être rapportées au postmaster | ||
+ | notify_classes = bounce, 2bounce, delay, policy, protocol, resource, software | ||
+ | #Ceci garde le message en file d' | ||
+ | #OK soft_bounce = yes | ||
+ | soft_bounce = no | ||
+ | debug_peer_list = 127.0.0.1 | ||
+ | debug_peer_level = 4 | ||
+ | smtpd_tls_loglevel = 3 | ||
+ | smtp_tls_loglevel = 3 | ||
+ | </ | ||
+ | |||
+ | sudo nano / | ||
+ | < | ||
+ | # | ||
+ | # Postfix master process configuration file. For details on the format | ||
+ | # of the file, see the master(5) manual page (command: "man 5 master" | ||
+ | # | ||
+ | # Do not forget to execute " | ||
+ | # | ||
+ | # ========================================================================== | ||
+ | # service type private unpriv | ||
+ | # | ||
+ | # ========================================================================== | ||
+ | smtp inet n | ||
+ | -o content_filter=spamassassin: | ||
+ | -o cleanup_service_name=pre-cleanup | ||
+ | -o receive_override_options=no_unknown_recipient_checks, | ||
+ | -o smtpd_sasl_auth_enable=yes | ||
+ | -o smtp_connect_timeout=1 | ||
+ | -o smtp_destination_rate_delay=1 | ||
+ | submission | ||
+ | -o content_filter=spamassassin: | ||
+ | -o cleanup_service_name=pre-cleanup | ||
+ | -o receive_override_options=no_unknown_recipient_checks, | ||
+ | -o smtpd_tls_security_level=encrypt | ||
+ | -o smtpd_sasl_auth_enable=yes | ||
+ | -o smtpd_client_restrictions=permit_sasl_authenticated, | ||
+ | -o smtp_connect_timeout=1 | ||
+ | -o smtp_destination_rate_delay=1 | ||
+ | smtps | ||
+ | -o content_filter=spamassassin: | ||
+ | -o cleanup_service_name=pre-cleanup | ||
+ | -o receive_override_options=no_unknown_recipient_checks, | ||
+ | -o smtpd_tls_wrappermode=yes | ||
+ | -o smtpd_sasl_auth_enable=yes | ||
+ | -o smtpd_client_restrictions=permit_sasl_authenticated, | ||
+ | -o smtp_connect_timeout=1 | ||
+ | -o smtp_destination_rate_delay=1 | ||
+ | # -o milter_macro_daemon_name=ORIGINATING | ||
+ | #628 | ||
+ | pickup | ||
+ | -o cleanup_service_name=pre-cleanup | ||
+ | pre-cleanup unix n | ||
+ | -o virtual_alias_maps= | ||
+ | cleanup | ||
+ | -o mime_header_checks= | ||
+ | -o nested_header_checks= | ||
+ | -o body_checks= | ||
+ | -o header_checks= | ||
+ | qmgr fifo n | ||
+ | #qmgr | ||
+ | tlsmgr | ||
+ | rewrite | ||
+ | bounce | ||
+ | defer | ||
+ | trace | ||
+ | verify | ||
+ | flush | ||
+ | proxymap | ||
+ | proxywrite unix - | ||
+ | smtp unix - | ||
+ | direct | ||
+ | # When relaying mail as backup MX, disable fallback_relay to avoid MX loops | ||
+ | relay | ||
+ | showq | ||
+ | error | ||
+ | retry | ||
+ | discard | ||
+ | local | ||
+ | virtual | ||
+ | -o virtual_destination_rate_delay=1 | ||
+ | lmtp unix - | ||
+ | anvil | ||
+ | scache | ||
+ | # | ||
+ | # ==================================================================== | ||
+ | # Interfaces to non-Postfix software. Be sure to examine the manual | ||
+ | # pages of the non-Postfix software to find out what options it wants. | ||
+ | # | ||
+ | # Many of the following services use the Postfix pipe(8) delivery | ||
+ | # agent. | ||
+ | # and other message envelope options. | ||
+ | # ==================================================================== | ||
+ | # ... | ||
+ | # ... | ||
+ | # | ||
+ | # flags= | ||
+ | dbmail-lmtp | ||
+ | -o disable_dns_lookups=yes | ||
+ | # clamav clamsmtpd + spamassassin spamd | ||
+ | scan unix - | ||
+ | -o smtp_send_xforward_command=yes | ||
+ | 127.0.0.1: | ||
+ | -o content_filter= | ||
+ | -o receive_override_options=no_unknown_recipient_checks, | ||
+ | -o smtpd_helo_restrictions= | ||
+ | -o smtpd_client_restrictions= | ||
+ | -o smtpd_sender_restrictions= | ||
+ | -o smtpd_recipient_restrictions=permit_mynetworks, | ||
+ | -o mynetworks_style=host | ||
+ | -o smtpd_authorized_xforward_hosts=127.0.0.1 | ||
+ | spamassassin | ||
+ | user=spamassassin | ||
+ | mailman unix - | ||
+ | flags=FR user=list: | ||
+ | argv=/ | ||
+ | </ | ||
+ | | ||
+ | === Dbmail sql query === | ||
+ | |||
+ | Création de / | ||
+ | sudo nano / | ||
+ | user = dbmail | ||
+ | password = password | ||
+ | hosts | ||
+ | dbname | ||
+ | query | ||
+ | |||
+ | Création de / | ||
+ | sudo nano / | ||
+ | user = dbmail | ||
+ | password = password | ||
+ | hosts | ||
+ | dbname | ||
+ | query | ||
+ | |||
+ | Création de / | ||
+ | < | ||
+ | sudo nano / | ||
+ | user = dbmail | ||
+ | password = password | ||
+ | hosts = 127.0.0.1 | ||
+ | dbname | ||
+ | query = SELECT alias FROM dbmail_aliases WHERE alias=' | ||
+ | </ | ||
+ | |||
+ | |||
+ | === Envoyer Directement === | ||
+ | |||
+ | * relayhost= | ||
+ | * renseigner transport_maps | ||
+ | |||
+ | * transport_maps = hash:/ | ||
+ | < | ||
+ | sudo nano / | ||
+ | mydomain.tld | ||
+ | # | ||
+ | </ | ||
+ | < | ||
+ | sudo postmap hash:/ | ||
+ | </ | ||
+ | |||
+ | * / | ||
+ | < | ||
+ | www postfix/ | ||
+ | </ | ||
+ | |||
+ | === Envoyer Indirectement (par relais) === | ||
+ | |||
+ | * relayhost=[smtp.sfr.fr]: | ||
+ | * ou relayhost= | ||
+ | |||
+ | * si le relais nécessite une // | ||
+ | < | ||
+ | sudo nano / | ||
+ | [smtp.sfr.fr]: | ||
+ | </ | ||
+ | sudo postmap hash:/ | ||
+ | |||
+ | < | ||
+ | sudo nano / | ||
+ | #cas 1 | ||
+ | # | ||
+ | mydomain.tld | ||
+ | #cas 2 | ||
+ | #gmail.com smtp: | ||
+ | # | ||
+ | # cas 3 | ||
+ | * | ||
+ | </ | ||
+ | sudo postmap hash:/ | ||
+ | |||
+ | * exemples; | ||
+ | < | ||
+ | expéditeur -> destinataire (transport) | ||
+ | toto@mydomain.tld envoie un mail vers tata@mydomain.tld | ||
+ | toto@mydomain.tld envoie un mail vers polo@gmail.com en utilisant le relais [smtp.gmail.com]: | ||
+ | toto@mydomain.tld envoie un mail vers arthur@orange.fr en utilisant le [smtp.sfr.fr]: | ||
+ | </ | ||
+ | |||
+ | * / | ||
+ | < | ||
+ | www postfix/ | ||
+ | </ | ||
+ | |||
+ | == SMTP accès à partir d'un MUA type thunderbird == | ||
+ | |||
+ | D' | ||
+ | - Interdit: depuis l' | ||
+ | - Autorisé : en 127.0.0.1, pas d' | ||
+ | - filtrage spamd clamsmtpd | ||
+ | |||
+ | * Serveur Sortant: smtp.domain.tld | ||
+ | * Port : 25, | ||
+ | * Nom utilisateur: | ||
+ | * Méthode d' | ||
+ | * Sécurité de la connexion : STARTTLS, TLS/SSL | ||
+ | |||
+ | ==x509 client== | ||
+ | |||
+ | * **Connexion forte** | ||
+ | a/ Si un certficat x509 client (format .p12) dans le magasin des certificats de thunderbird est associé à toto@domain.tld, | ||
+ | < | ||
+ | sudo nano / | ||
+ | A8: | ||
+ | </ | ||
+ | L' | ||
+ | |||
+ | b/ Cela ouvre la possibilité d' | ||
+ | Par exemple en adaptant un port existant ou en ajoutant; | ||
+ | |||
+ | < | ||
+ | 5678 inet n | ||
+ | -o content_filter=spamassassin: | ||
+ | -o receive_override_options=no_unknown_recipient_checks, | ||
+ | -o smtpd_sasl_auth_enable=no | ||
+ | -o smtp_sasl_auth_enable=no | ||
+ | -o smtpd_enforce_tls=yes | ||
+ | -o smtpd_tls_ask_ccert=yes | ||
+ | -o smtpd_tls_req_ccert=yes | ||
+ | -o smtpd_client_restrictions=permit_tls_clientcerts, | ||
+ | -o smtpd_relay_restrictions=permit_tls_clientcerts, | ||
+ | -o smtpd_sender_restrictions=reject_unlisted_sender, | ||
+ | </ | ||
+ | Au niveau du MUA type thunderbird, | ||
+ | -nom du serveur SMTP= smtp.domain.tld | ||
+ | -Port= 5678 | ||
+ | -Nom utilisateur= non spécifié | ||
+ | -Méthode d' | ||
+ | -Sécurité de la connexion= STARTTLS obligatoire | ||
+ | |||
+ | //telnet avec x509client// | ||
+ | < | ||
+ | openssl s_client -connect smtp.domain.tld: | ||
+ | .... | ||
+ | Acceptable client certificate | ||
+ | </ | ||
+ | Pour le telnet, il faut le format certificat.pem et key.pem au lieu du p12 | ||
+ | |||
+ | //telnet sans x509client// | ||
+ | < | ||
+ | openssl s_client -connect smtp.domain.tld: | ||
+ | ... | ||
+ | No client certificate presented | ||
+ | </ | ||
+ | La session échoue après le ehlo. | ||
+ | |||
+ | * **Signature forte** | ||
+ | Pour signer votre mail, il vous faut le format .p12 (pkcs12). La signature sera traduite en pkcs7. | ||
+ | |||
+ | * **Chiffrement fort** | ||
+ | Pour chiffrer un mail en utilisant une authentification forte, il faut le x509 client du destinataire au format pem, sans sa clef privée. Si Toto veut envoyer un mail chiffré (SMIME pkcs7) à Tata, alors toto doit avoir dans le magasin des certficats x509 thunderbird: | ||
+ | |||
+ | == Service == | ||
+ | |||
+ | < | ||
+ | sudo postfix < | ||
+ | </ | ||
+ | |||
+ | ====== Dbmail ====== | ||
+ | |||
+ | ===== Dbmail 3.x ===== | ||
+ | |||
+ | * gestion et stockage via les tables mysql, postgresql, oracle | ||
+ | * adapté à la messagerie de masse et aux méthodes virtuelles de Postfix. | ||
+ | |||
+ | sudo nano / | ||
+ | < | ||
+ | # stable all deb | ||
+ | deb http:// | ||
+ | # sid | ||
+ | deb http:// | ||
+ | # lucid | ||
+ | deb http:// | ||
+ | # ppa Leonel Nunez | ||
+ | deb http:// | ||
+ | deb-src http:// | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | === build-packages-from-source === | ||
+ | |||
+ | * / | ||
+ | < | ||
+ | * Chacun des appels apt-get va se plaindre de dépendances manquantes (*note). Juste les installer manuellement, | ||
+ | < | ||
+ | sudo apt-get -b source libsieve | ||
+ | sudo dpkg -i libsieve*.deb | ||
+ | sudo apt-get -b source libzdb | ||
+ | sudo dpkg -i libzdb*.deb | ||
+ | sudo apt-get -b source dbmail | ||
+ | sudo dpkg -i dbmail*.deb | ||
+ | </ | ||
+ | |||
+ | === build-from-tar.tgz=== | ||
+ | |||
+ | * Installer les lib-dev relatives à GLIB, GMIME, SIEVE, MHASH, ZDB, LIBEVENT (*note) | ||
+ | < | ||
+ | ./configure --with-zdb=/ | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | make all | ||
+ | sudo make install | ||
+ | </ | ||
+ | Les fichiers sont copiés par défault dans / | ||
+ | |||
+ | |||
+ | ==== Dbmail 2.2 (obsolète)==== | ||
+ | |||
+ | |||
+ | ===== Configuration ===== | ||
+ | ==== dbmail 3.0 ==== | ||
+ | [[http:// | ||
+ | |||
+ | |||
+ | ==== dbmail 2.2 ==== | ||
+ | |||
+ | === la base de données === | ||
+ | |||
+ | Création du schema dbmail | ||
+ | mysql -uroot -p | ||
+ | mysql> CREATE schema dbmail; | ||
+ | mysql> | ||
+ | |||
+ | Récupération et décompression du modèle de table : | ||
+ | cp / | ||
+ | gzip --decompress ~/ | ||
+ | |||
+ | Création des tables | ||
+ | mysql -uroot -p dbmail < ~/ | ||
+ | |||
+ | Création d'un utilisateur dbmail | ||
+ | mysql -uroot -p | ||
+ | GRANT ALL ON dbmail.* to dbmail@localhost identified by ' | ||
+ | |||
+ | === dbmail === | ||
+ | |||
+ | Modification des lignes suivantes dans / | ||
+ | sudo vim / | ||
+ | driver = mysql | ||
+ | authdriver = sql | ||
+ | host = localhost | ||
+ | sqlsocket = / | ||
+ | user = dbmail | ||
+ | pass = password | ||
+ | db = dbmail | ||
+ | SIEVE_NOTIFY = no | ||
+ | |||
+ | Modification de / | ||
+ | sudo vim / | ||
+ | START_IMAPD=1 | ||
+ | START_LMTPD=1 | ||
+ | START_SIEVE=1 | ||
+ | |||
+ | Redémarrage de dbmail | ||
+ | sudo service dbmail restart | ||
+ | |||
+ | ==== Compte Boîte aux Lettres - Mailbox | ||
+ | **sudo dbmail-users** | ||
+ | * -a //ajouter un nouveau Compte// | ||
+ | * -w //mot de passe// | ||
+ | * -p // | ||
+ | * -c //mise à jour du compte// | ||
+ | * -s //créer// une adresse mail ou plusieurs alias -s toto@domain.tld, | ||
+ | * -S // | ||
+ | * -m //quota// -m 50M | ||
+ | * -d // | ||
+ | * -x toto@domain.tld -t forward@domain2.tld2 | ||
+ | * -x toto@domain.tld -T forward@domain2.tld2 | ||
+ | |||
+ | ** Ajouter & Créer un nouveau compte toto@domain.tld avec son adresse mail toto@domain.tld** | ||
+ | < | ||
+ | sudo dbmail-users -a toto@domain.ltd -w mypass -p md5 -s toto@domain.ltd | ||
+ | Adding INBOX for new user... ok. | ||
+ | [toto@domain.tld] | ||
+ | Done | ||
+ | </ | ||
+ | |||
+ | Supprimer un compte | ||
+ | < | ||
+ | sudo dbmail-users -d toto@domain.tld | ||
+ | </ | ||
+ | http:// | ||
+ | |||
+ | | ||
+ | |||
+ | Dbmail utilise saslauthd comme démon d' | ||
+ | Rimap (Requête d' | ||
+ | Pam n'est pas vraiment adapté pour la messagerie de masse et il y a toujours moyen de convertir un user unix/pam en virtual/ | ||
+ | |||
+ | === Convertir un utilisateur Unix/Pam en Virtual/ | ||
+ | |||
+ | sudo nano / | ||
+ | < | ||
+ | user_unix | ||
+ | user_unix@domain.tld | ||
+ | </ | ||
+ | < | ||
+ | sudo postmap hash:/ | ||
+ | sudo postconf -e ' | ||
+ | sudo dbmail-users -a user_virtual@domain.tld -s user_virtual@domain.tld -w mot_de_passe | ||
+ | </ | ||
+ | user_virtual@domain.tld sert de récipient. | ||
+ | |||
+ | === / | ||
+ | |||
+ | * avec RIMAP | ||
+ | < | ||
+ | START=yes | ||
+ | NAME=" | ||
+ | MECHANISMS=" | ||
+ | MECH_OPTIONS=" | ||
+ | THREADS=5 | ||
+ | OPTIONS=" | ||
+ | </ | ||
+ | * Service | ||
+ | < | ||
+ | sudo service saslauthd restart|reload | ||
+ | </ | ||
+ | ==== postfix sasl==== | ||
+ | === main.cf === | ||
+ | à titre d' | ||
+ | |||
+ | == smtp_sasl_password_maps == | ||
+ | Sert principalement à s' | ||
+ | ( voir relayhost, transport_maps ) | ||
+ | |||
+ | sudo nano / | ||
+ | < | ||
+ | [11.22.22.44]: | ||
+ | [smtp.gmail.com]: | ||
+ | </ | ||
+ | < | ||
+ | sudo postmap / | ||
+ | sudo postconf -e ' | ||
+ | </ | ||
+ | === master.cf === | ||
+ | |||
+ | < | ||
+ | submission | ||
+ | .... | ||
+ | -o smtpd_sasl_auth_enable=yes | ||
+ | -o smtpd_client_restrictions=permit_sasl_authenticated, | ||
+ | </ | ||
+ | Optionnellement, | ||
+ | |||
+ | ==== Mise en place du CRAM-MD5 ==== | ||
+ | |||
+ | - authentification en clair : PLAIN, LOGIN | ||
+ | - authentifcation chiffrée : CRAM-MD5, DIGEST-MD5 | ||
+ | * le mech_list n'a aucun rapport avec le type de stockage des mots de passe. | ||
+ | * cram-md5 a un stockage // | ||
+ | [[http:// | ||
+ | < | ||
+ | sudo dbmail-users -c toto@domain.tld -p plaintext -w password | ||
+ | </ | ||
+ | * / | ||
+ | < | ||
+ | sudo ln -s / | ||
+ | sudo ln -s / | ||
+ | </ | ||
+ | |||
+ | * pwcheck_method: | ||
+ | < | ||
+ | pwcheck_method: | ||
+ | mech_list: PLAIN LOGIN | ||
+ | </ | ||
+ | Ne pas préciser d' | ||
+ | |||
+ | * pwcheck_method: | ||
+ | < | ||
+ | pwcheck_method: | ||
+ | mech_list: CRAM-MD5 PLAIN | ||
+ | auxprop_plugin: | ||
+ | log_level: 2 | ||
+ | sql_engine: mysql | ||
+ | sql_hostnames: | ||
+ | sql_user: dbmail | ||
+ | sql_passwd: pass | ||
+ | sql_database: | ||
+ | sql_verbose: | ||
+ | sql_select: SELECT passwd FROM dbmail_users WHERE userid = ' | ||
+ | </ | ||
+ | NB: userid = ' | ||
+ | [[http:// | ||
+ | |||
+ | * postfix main.cf | ||
+ | < | ||
+ | smtp_sasl_mechanism_filter = cram-md5 plain | ||
+ | </ | ||
+ | * / | ||
+ | < | ||
+ | postfix/ | ||
+ | postfix/ | ||
+ | </ | ||
+ | |||
+ | * testsaslauthd (login, | ||
+ | < | ||
+ | sudo testsaslauthd -f / | ||
+ | 0: OK " | ||
+ | </ | ||
+ | * test avec roundcube | ||
+ | < | ||
+ | 18:49:46 www roundcube: [77EB] C: A0001 ID (" | ||
+ | 18:49:46 www roundcube: [77EB] S: * ID (" | ||
+ | 18:49:46 www roundcube: [77EB] S: A0001 OK ID completed | ||
+ | 18:49:46 www roundcube: [77EB] C: A0002 AUTHENTICATE CRAM-MD5 | ||
+ | 18:49:46 www roundcube: [77EB] S: + MTM0MzA2MjE4Ni4xOTIzMy4yNkAobm9uZSk= | ||
+ | 18:49:46 www roundcube: [77EB] C: dG90b0Bkb21haW4udGxkIDI1NmMyNmIxYmY4MjE5YjJlZjUxMTNlNTVjYjAwYmFk | ||
+ | 18:49:46 www roundcube: [77EB] S: A0002 OK [CAPABILITY IMAP4rev1 ACL RIGHTS=texk NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE | ||
+ | STARTTLS ID] User toto@domain.tld authenticated | ||
+ | </ | ||
+ | |||
+ | ==== Statistiques des connexions | ||
+ | |||
+ | * / | ||
+ | < | ||
+ | authlog | ||
+ | </ | ||
+ | * Rafraîchir en supprimant les 8000 premières lignes & enregistrements. | ||
+ | < | ||
+ | delete from dbmail_authlog where id < 8000; | ||
+ | </ | ||
+ | * Lister les 10 dernières connexions. | ||
+ | < | ||
+ | SELECT * FROM dbmail_authlog order by id desc limit 10; | ||
+ | </ | ||
+ | * Les traces des 10 derniers mails par date/time. | ||
+ | < | ||
+ | SELECT * FROM dbmail_physmessage order by internal_date desc limit 10; | ||
+ | </ | ||
+ | |||
+ | ===== Alias et Forward ===== | ||
+ | |||
+ | | ||
+ | |||
+ | Losque les domaines appartiennent au même mx, il s'agit plutôt d' | ||
+ | |||
+ | < | ||
+ | sudo dbmail-users -c toto@domain.tld -s toto@domain.tld, | ||
+ | </ | ||
+ | < | ||
+ | smtpd_sasl_local_domain = domain.tld domain2.tld2 domain3.tld3 | ||
+ | </ | ||
+ | ==== Forward ==== | ||
+ | Lorsque les mx sont différents, | ||
+ | |||
+ | === Pour envoyer, reécrire l' | ||
+ | |||
+ | pour envoyer des mails, sender_canonical_maps est suffisant | ||
+ | |||
+ | sudo nano / | ||
+ | < | ||
+ | yoko | ||
+ | yoko@domain.tld | ||
+ | </ | ||
+ | < | ||
+ | sudo postmap hash:/ | ||
+ | sudo postconf -e ' | ||
+ | </ | ||
+ | |||
+ | test | ||
+ | < | ||
+ | yoko@pc:~$ echo ' | ||
+ | </ | ||
+ | yoko devient babar@monmail.com, | ||
+ | |||
+ | === Recevoir et Faire Suivre automatiquement le courrier=== | ||
+ | |||
+ | le courrier à destination de toto@domain.tld est renvoyé chez casimir@free.fr | ||
+ | < | ||
+ | sudo dbmail-users -x toto@domain.tld -t casimir@free.fr | ||
+ | </ | ||
+ | |||
+ | === Créer un clone de Mailbox d'un mx différent=== | ||
+ | |||
+ | >sudo apt-get install imapsync | ||
+ | Dans l' | ||
+ | * host1 est la source, host2 est la destination. | ||
+ | |||
+ | * Simuler avec --dry | ||
+ | < | ||
+ | imapsync --host1 imap.gmail.com --user1 compte@gmail.com --password1 motdepasse_gmail --port1 993 --ssl1 --authmech1 LOGIN --host2 mail.domain.tld --user2 yoko@domain.tld --password2 motdepasse_yoko --dry | ||
+ | </ | ||
+ | * Copier réellement | ||
+ | < | ||
+ | imapsync --host1 imap.gmail.com --user1 compte@gmail.com --password1 motdepasse_gmail --port1 993 --ssl1 --authmech1 LOGIN --host2 mail.domain.tld --user2 yoko@domain.tld --password2 motdepasse_yoko | ||
+ | </ | ||
+ | |||
+ | === Recevoir et Rapatrier du courrier === | ||
+ | |||
+ | >sudo apt-get install fetchmail | ||
+ | fetchmailconf sert à rien et risque de vous induire en erreurs. | ||
+ | |||
+ | Dans l' | ||
+ | |||
+ | sudo nano / | ||
+ | < | ||
+ | # Read the ISP accounts every 3600 seconds | ||
+ | set syslog | ||
+ | set daemon 3600 | ||
+ | |||
+ | # Configure the ISP accounts (POP server, users and respective passwords) | ||
+ | poll imap.gmail.com with protocol IMAP: | ||
+ | user " | ||
+ | smtphost smtp.domain.tld | ||
+ | </ | ||
+ | [[http:// | ||
+ | |||
+ | Fetchmail relève toutes les heures les mails de babar@monmail.com et les rapatrie directement sur yoko@domain.tld. | ||
+ | * keep signifie que fetchmail crée une copie du mail sans le détruire sur le serveur distant. | ||
+ | * sender_canonical_maps a été défini. | ||
+ | * sudo service fetchmail restart # pour relançer le démon. | ||
+ | |||
+ | Fetchmail fait un doublon, voir inutile, | ||
+ | * exemple en modifiant le main.inc.php de roundcube | ||
+ | |||
+ | < | ||
+ | $rcmail_config[' | ||
+ | .... | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | // | ||
+ | |||
+ | ===== Notifications ===== | ||
+ | |||
+ | ==== dbmail_auto_notifications ==== | ||
+ | |||
+ | >/ | ||
+ | < | ||
+ | AUTO_NOTIFY | ||
+ | # Defaults to AUTO_NOTIFY_SUBJECT ="NEW MAIL NOTIFICATION" | ||
+ | # AUTO_NOTIFY_SUBJECT | ||
+ | # Defaults to AUTO_NOTIFY_SENDER " | ||
+ | AUTO_NOTIFY_SENDER | ||
+ | </ | ||
+ | |||
+ | notify_address: | ||
+ | < | ||
+ | INSERT INTO dbmail_auto_notifications ( user_idnr, notify_address ) VALUES ( ' | ||
+ | </ | ||
+ | |||
+ | Dès qu'un mail arrive chez modo@domain.tld(user_idnr=' | ||
+ | |||
+ | Attention, autonotify@dbmail génère une erreur car évidemment le récipient n'est pas connu. | ||
+ | |||
+ | ==== dbmail_auto_replies ==== | ||
+ | |||
+ | Chaque utilisateur peut spécifier un message de réponse automatique à tous les messages entrants. | ||
+ | >/ | ||
+ | AUTO_REPLY | ||
+ | < | ||
+ | INSERT INTO dbmail_auto_replies ( user_idnr, start_date, stop_date, reply_body ) VALUES ( ' | ||
+ | </ | ||
+ | ===== Filtrer les Headers & dbmail_filters ===== | ||
+ | |||
+ | dbmail_filters permet principalement de rediriger un mail vers une mailbox en fonction du header. | ||
+ | * pour lister les identifiants; | ||
+ | * Pour lister les mailboxes; select name from dbmail_mailboxes where owner_idnr=' | ||
+ | < | ||
+ | insert into dbmail_filters ( user_id, headername, headervalue, | ||
+ | insert into dbmail_filters ( user_id, headername, headervalue, | ||
+ | </ | ||
+ | dbmail_filters est insensible à la casse de polices, et comprendre user_id comme user_idnr (lapsus avec userid). | ||
+ | |||
+ | * Annexe Header | ||
+ | < | ||
+ | select headername from dbmail_headername order by headername; | ||
+ | </ | ||
+ | |||
+ | ===== Shared Mailboxes ===== | ||
+ | Ces boîtes sont appelées boîtes aux lettres partagées - Elles sont décrites dans la table // | ||
+ | |||
+ | Lister les identifiants et récupérer le user_idnr | ||
+ | < | ||
+ | select user_idnr, | ||
+ | +-----------+--------------------------------+------------------------------------+ | ||
+ | | user_idnr | userid | ||
+ | +-----------+--------------------------------+------------------------------------+ | ||
+ | | 1 | __@!internal_delivery_user!@__ | | | ||
+ | | 2 | anyone | ||
+ | | 3 | __public__ | ||
+ | .... | ||
+ | sudo dbmail-users -l __public__ | awk -F: ' | ||
+ | </ | ||
+ | ==== dbmail-acl.sh ==== | ||
+ | [[http:// | ||
+ | Ce script permet de créer plus facilement les boîtes aux lettres partagées. | ||
+ | |||
+ | < | ||
+ | mkdir ~/dbmail ; cd ~/dbmail | ||
+ | wget http:// | ||
+ | sudo cp / | ||
+ | sudo chown votre_user: | ||
+ | sudo chmod +x dbmail-acl.sh | ||
+ | </ | ||
+ | Renseigner la partie | ||
+ | < | ||
+ | DBMAIL[_dbmail_mysqldatabase]=" | ||
+ | DBMAIL[_dbmail_mysqluser]=" | ||
+ | DBMAIL[_dbmail_mysqlpassword]=" | ||
+ | DBMAIL[_dbmail_mysqlhost]=" | ||
+ | DBMAIL[_dbmail_conffile]="/ | ||
+ | DBMAIL[_dbmail_driver]=" | ||
+ | </ | ||
+ | modifier pour dbmail 3.x à proximité de function get_all_acls() | ||
+ | < | ||
+ | $MYSQL_CLIENT -N -e " | ||
+ | </ | ||
+ | et acl_add() | ||
+ | < | ||
+ | | ||
+ | </ | ||
+ | === Utilisation === | ||
+ | |||
+ | * dbmail-acl.sh add|del user owner [mailbox] | ||
+ | |||
+ | Ajoute ou supprime une mailbox partagée du propriétaire qui peut être accédée par tel utilisateur. La valeur par défaut est la boîte de réception (INBOX) | ||
+ | * dbmail-acl.sh add|del user owner ' | ||
+ | |||
+ | Pour avoir accès à toutes les boîtes de propriétaire, | ||
+ | |||
+ | |||
+ | * dbmail-acl.sh list [command] | ||
+ | |||
+ | command est acl ou mailbox. La valeur par défaut est acl. | ||
+ | |||
+ | * dbmail-acl.sh list acl [userid] | ||
+ | |||
+ | Liste les ACL pour tel userid. La valeur par défaut est tous les userid sont sélectionnés. | ||
+ | |||
+ | * dbmail-acl.sh list mailbox [userid] | ||
+ | |||
+ | Liste toutes les mailboxes pour tel userid. La valeur par défaut est toutes les mailboxes sont sélectionnées. | ||
+ | ==== Mailbox ==== | ||
+ | |||
+ | Au besoin, si dbmail-acl.sh ne crée pas les mailboxes. | ||
+ | |||
+ | * création manuelle mailbox anyone | ||
+ | < | ||
+ | insert INTO dbmail_mailboxes (owner_idnr, | ||
+ | </ | ||
+ | * création manuelle mailbox public | ||
+ | < | ||
+ | insert INTO dbmail_mailboxes (owner_idnr, | ||
+ | </ | ||
+ | |||
+ | ==== #Users ==== | ||
+ | en supposant que vous ayez 3 comptes distincts; | ||
+ | < | ||
+ | sudo dbmail-users -a t1@domain.tld -s t1@domain.tld -w t1 | ||
+ | sudo dbmail-users -a t2@domain.tld -s t2@domain.tld -w t2 | ||
+ | sudo dbmail-users -a t3@domain.tld -s t3@domain.tld -w t3 | ||
+ | </ | ||
+ | |||
+ | **t1@mdomain.tld partage sa mailbox avec t2@domain.tld et t3@domain.tld** | ||
+ | < | ||
+ | sudo bash ~/ | ||
+ | Taking default mailbox INBOX | ||
+ | Adding (full) acl rights for 26 to 60. | ||
+ | Adding subscription of 26 to 60. | ||
+ | sudo bash ~/ | ||
+ | Taking default mailbox INBOX | ||
+ | Adding (full) acl rights for 27 to 60. | ||
+ | Adding subscription of 27 to 60. | ||
+ | </ | ||
+ | |||
+ | === Messagerie de t2@domain.tld === | ||
+ | |||
+ | La messagerie t1@domain.tld est partagée et incluse dans celle de t2@domain.tld. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | ==== #Public ==== | ||
+ | en supposant que vous ayez 1 compte distinct; | ||
+ | < | ||
+ | sudo dbmail-users -a entreprise@domain.tld -s entreprise@domain.tld -w entreprise | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | sudo bash ~/ | ||
+ | Taking default mailbox INBOX | ||
+ | Adding (full) acl rights for 28 to 51. | ||
+ | Adding subscription of 28 to 51. | ||
+ | </ | ||
+ | |||
+ | ajouter une adresse mail ' | ||
+ | < | ||
+ | insert into dbmail_aliases ( alias, deliver_to, client_idnr ) value ( ' | ||
+ | </ | ||
+ | {{: | ||
+ | |||
+ | |||
+ | |||
+ | ===== Mailman ===== | ||
+ | ==== Ajouter les Recipients ==== | ||
+ | C'est l' | ||
+ | |||
+ | sudo nano dbmail-add-list | ||
+ | < | ||
+ | #!/bin/bash | ||
+ | #14/07/2012 | ||
+ | # sudo bash dbmail-addl-list < | ||
+ | #DOMAINNAME est le domaine de messagerie | ||
+ | |||
+ | if [ " | ||
+ | echo "No maillist specified" | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | DOMAINNAME=" | ||
+ | # | ||
+ | |||
+ | MAILLIST=$1 | ||
+ | |||
+ | echo " | ||
+ | dbmail-users -x $MAILLIST$DOMAINNAME -t " | ||
+ | |||
+ | for i in admin bounces confirm join leave owner request subscribe unsubscribe; | ||
+ | do | ||
+ | echo " | ||
+ | dbmail-users -x $MAILLIST-$i$DOMAINNAME -t " | ||
+ | done | ||
+ | </ | ||
+ | === exemple pour la liste " | ||
+ | * Création< | ||
+ | * Ajouter les Récipients | ||
+ | sudo bash / | ||
+ | < | ||
+ | dbmail-users -x pub@list.domain.tld -t " | ||
+ | [|/ | ||
+ | Done | ||
+ | dbmail-users -x pub-admin@list.domain.tld -t " | ||
+ | [|/ | ||
+ | Done | ||
+ | ... | ||
+ | ....... | ||
+ | dbmail-users -x pub-subscribe@list.domain.tld -t " | ||
+ | [|/ | ||
+ | Done | ||
+ | dbmail-users -x pub-unsubscribe@list.domain.tld -t " | ||
+ | [|/ | ||
+ | Done | ||
+ | </ | ||
+ | * Lister les listes | ||
+ | < | ||
+ | sudo list_lists | ||
+ | 2 listes correspondantes trouvées | ||
+ | | ||
+ | Pub | ||
+ | </ | ||
+ | * Supprimer une liste | ||
+ | < | ||
+ | sudo rmlist pub | ||
+ | </ | ||
+ | |||
+ | ==== Annexe mailman ==== | ||
+ | |||
+ | * master.cf | ||
+ | < | ||
+ | mailman unix - | ||
+ | flags=FR user=list: | ||
+ | argv=/ | ||
+ | </ | ||
+ | * transport_maps | ||
+ | < | ||
+ | list.domain.tld | ||
+ | </ | ||
+ | * check permissions | ||
+ | < | ||
+ | sudo check_perms; | ||
+ | </ | ||
+ | * Problème éventuel de Redirection | ||
+ | < | ||
+ | [[http:// | ||
+ | ===== Web-based DbmailAdmin ===== | ||
+ | Les interfaces graphiques à base de LAMP ou équivalent, | ||
+ | - [[http:// | ||
+ | - [[http:// | ||
+ | |||
+ | ===== Pare-feu ===== | ||
+ | |||
+ | Ne pas oublier d' | ||
+ | |||
+ | Exemple avec shorewall : | ||
+ | sudo vim / | ||
+ | IMAP/ | ||
+ | SMTP/ | ||
+ | |||
+ | redémarrage du pare-feu | ||
+ | sudo / | ||
+ | |||
+ | ===== Auth Basic Apache SASL SMTP===== | ||
+ | |||
+ | Juste un extra de configuration, | ||
+ | |||
+ | * Ajouter sasldb à MECHANISMS dans le / | ||
+ | < | ||
+ | MECHANISMS=" | ||
+ | </ | ||
+ | / | ||
+ | < | ||
+ | pwcheck_method: | ||
+ | mech_list: CRAM-MD5 PLAIN LOGIN | ||
+ | saslauthd_path: | ||
+ | sasldb_path: | ||
+ | auxprop_plugin: | ||
+ | log_level: 7 | ||
+ | sql_engine: mysql | ||
+ | sql_hostnames: | ||
+ | sql_user: dbmail | ||
+ | sql_passwd: pass | ||
+ | sql_database: | ||
+ | sql_verbose: | ||
+ | sql_select: SELECT passwd FROM dbmail_users WHERE userid=' | ||
+ | </ | ||
+ | * Virtualhost apache | ||
+ | < | ||
+ | #requis saslauthd + sasldb | ||
+ | |||
+ | Alias / | ||
+ | < | ||
+ | ... | ||
+ | AuthType Basic | ||
+ | AuthName " | ||
+ | AuthBasicProvider sasl | ||
+ | AuthBasicAuthoritative On | ||
+ | AuthSaslPwcheckMethod sasldb | ||
+ | AuthSaslRealm domain.tld | ||
+ | AuthSaslDbPath / | ||
+ | AuthSaslServiceName smtp | ||
+ | Require user toto@domain.tld | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | sudo ln -s /etc/sasldb / | ||
+ | #creation de toto@domain.tld | ||
+ | sudo saslpasswd2 | ||
+ | #listing de la database | ||
+ | sudo sasldblistusers2 -f /etc/sasldb | ||
+ | </ | ||
+ | login: toto@domain.tld ; mot-de-passe: | ||
+ | |||
+ | ===== Auth Digest Apache dbmail_users ===== | ||
+ | |||
+ | Dans l' | ||
+ | |||
+ | Virtualhost avec mod_auth_digest, | ||
+ | < | ||
+ | DBDriver mysql | ||
+ | DBDParams " | ||
+ | DBDMin | ||
+ | DBDKeep 2 | ||
+ | DBDMax | ||
+ | DBDExptime 240 | ||
+ | |||
+ | Alias /example2 "/ | ||
+ | < | ||
+ | | ||
+ | | ||
+ | Order allow,deny | ||
+ | Allow from all | ||
+ | AuthType Digest | ||
+ | AuthDigestAlgorithm MD5 | ||
+ | AuthName " | ||
+ | AuthDigestProvider dbd | ||
+ | Require valid-user | ||
+ | # passwd a été stocké en plaintext | ||
+ | AuthDBDUserRealmQuery " | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== Voir aussi ===== | ||
+ | |||
+ | * **(en)** [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | ---- | ||
+ | |||
+ | // |