Initial commit: VPS tutorial complet (105 etapes)
This commit is contained in:
151
07-mail.md
Normal file
151
07-mail.md
Normal file
@@ -0,0 +1,151 @@
|
||||
# 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 : `<DOMAINE>`
|
||||
- Enable DKIM : cocher
|
||||
- Generate DKIM Private-key
|
||||
|
||||
## Ajouter DMARC
|
||||
|
||||
ISPConfig > DNS > Zones > `<DOMAINE>` > Records > TXT :
|
||||
- Hostname : `_dmarc`
|
||||
- Text : `v=DMARC1;p=reject;sp=quarantine;pct=100;rua=mailto:<EMAIL>`
|
||||
|
||||
## Verifier SPF
|
||||
|
||||
Doit deja exister (cree par le template) :
|
||||
```
|
||||
TXT <DOMAINE>. v=spf1 mx a ~all
|
||||
```
|
||||
|
||||
## Configurer Postfix
|
||||
|
||||
```bash
|
||||
# Verifier dans /etc/postfix/main.cf :
|
||||
myhostname = mail.<DOMAINE>
|
||||
```
|
||||
|
||||
## Sous-domaine webmail (Roundcube)
|
||||
|
||||
1. DNS A `mail` -> `<IP>`
|
||||
2. ISPConfig > Sites > Subdomain (vhost) : `mail.<DOMAINE>`
|
||||
3. Apache Directives :
|
||||
|
||||
```apache
|
||||
<Proxy *>
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</Proxy>
|
||||
|
||||
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.<DOMAINE>
|
||||
```
|
||||
|
||||
## Sous-domaine Rspamd
|
||||
|
||||
Meme principe avec proxy vers `https://<DOMAINE>:8081/rspamd/`.
|
||||
|
||||
## Autoconfig (Thunderbird/Android)
|
||||
|
||||
1. Sous-domaine `autoconfig.<DOMAINE>` avec Apache Directives :
|
||||
|
||||
```apache
|
||||
<FilesMatch "^.+\.xml$">
|
||||
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
|
||||
<FilesMatch "^.+\.json$">
|
||||
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
|
||||
AddHandler application/x-httpd-php .php .xml .json
|
||||
|
||||
<IfModule mod_speling.c>
|
||||
CheckCaseOnly on
|
||||
CheckSpelling on
|
||||
</IfModule>
|
||||
```
|
||||
|
||||
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@<DOMAINE> votre@email.com
|
||||
```
|
||||
|
||||
## MAILER_DSN pour Symfony
|
||||
|
||||
```
|
||||
MAILER_DSN=smtp://127.0.0.1:25?auto_tls=false
|
||||
```
|
||||
Reference in New Issue
Block a user