# 7. Mail ## Desactiver amavisd ```bash systemctl stop amavisd-new 2>/dev/null systemctl disable amavisd-new 2>/dev/null ``` ## Configurer Rspamd Voir `scripts/setup_rspamd.py` pour le script complet. Fichiers crees : - `/etc/rspamd/local.d/classifier-bayes.conf` — apprentissage Bayes + Redis - `/etc/rspamd/local.d/redis.conf` — serveur Redis - `/etc/rspamd/local.d/metrics.conf` — seuils spam - `/etc/rspamd/local.d/history_redis.conf` — historique - `/etc/rspamd/local.d/url_reputation.conf` — reputation URLs - `/etc/rspamd/local.d/mx_check.conf` — verification MX - `/etc/rspamd/local.d/neural.conf` — reseau de neurones - `/etc/rspamd/local.d/neural_group.conf` — groupes neurones - `/etc/rspamd/local.d/milter_headers.conf` — headers spam - `/etc/rspamd/local.d/arc.conf` — protocole ARC - `/etc/rspamd/local.d/antivirus.conf` — ClamAV - `/etc/rspamd/local.d/groups.conf` — groupes antivirus - `/etc/rspamd/local.d/antivirus_group.conf` — detection virus ```bash a2enmod proxy systemctl restart apache2 systemctl restart rspamd ``` ## Dovecot Sieve (apprentissage spam/ham) Voir `scripts/setup_dovecot_sieve.py`. Configure : - Deplacement vers Junk = apprend comme spam - Deplacement depuis Junk = apprend comme ham - Quota warning a 90% Installer les plugins necessaires : ```bash apt install dovecot-sieve dovecot-managesieved ``` ## Creer le domaine mail ISPConfig > **Email > Domain > Add new Domain** - Domain : `` - Enable DKIM : cocher - Generate DKIM Private-key ## Ajouter DMARC ISPConfig > DNS > Zones > `` > Records > TXT : - Hostname : `_dmarc` - Text : `v=DMARC1;p=reject;sp=quarantine;pct=100;rua=mailto:` ## Verifier SPF Doit deja exister (cree par le template) : ``` TXT . v=spf1 mx a ~all ``` ## Configurer Postfix ```bash # Verifier dans /etc/postfix/main.cf : myhostname = mail. ``` ## Sous-domaine webmail (Roundcube) 1. DNS A `mail` -> `` 2. ISPConfig > Sites > Subdomain (vhost) : `mail.` 3. Apache Directives : ```apache Order deny,allow Allow from all ProxyRequests Off ProxyPass /stats ! ProxyPass /.well-known/acme-challenge ! SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 SSLProxyEngine On ProxyPreserveHost On SSLProxyVerify none SSLProxyCheckPeerCN off SSLProxyCheckPeerName off SSLProxyCheckPeerExpire off ProxyPass /webmail https://localhost:8080/webmail/ ProxyPass / https://localhost:8080/webmail/ ProxyPassReverse / https://localhost:8080/webmail/ RedirectMatch ^/$ https://mail. ``` ## Sous-domaine Rspamd Meme principe avec proxy vers `https://:8081/rspamd/`. ## Autoconfig (Thunderbird/Android) 1. Sous-domaine `autoconfig.` avec Apache Directives : ```apache SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost" SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost" AddHandler application/x-httpd-php .php .xml .json CheckCaseOnly on CheckSpelling on ``` 2. Creer le fichier `autoconfig/mail/config-v1.1.xml` (voir scripts/setup_autoconfig.py) 3. Mettre a jour PHP-FPM : ajouter `.xml .json` dans `security.limit_extensions` ## Autodiscover (Outlook) Meme sous-domaine pointant vers le meme dossier `autoconfig`. Creer `autoconfig/Autodiscover/Autodiscover.xml`. ## Creer une boite mail ISPConfig > **Email > Email Mailbox > Add new Mailbox** ## Tester l'envoi ```bash echo "Test" | mail -s "Test" -r contact@ votre@email.com ``` ## MAILER_DSN pour Symfony ``` MAILER_DSN=smtp://127.0.0.1:25?auto_tls=false ```