Integrate SpamAssassin with Postfix mail delivery
This commit is contained in:
1 parent
3afdbb08ad
commit
de9a560f6a
5 files changed
+92
-3
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
[Service]
|
||||||
|
PIDFile=/run/spamass/spamass.pid
|
||||||
|
RemainAfterExit=no
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Merge into /etc/postfix/main.cf. Keep any other smtpd_milters on this list.
|
||||||
|
smtpd_milters = { unix:spamass/spamass.sock, connect_timeout=3s, content_timeout=30s, default_action=accept }
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# /etc/default/spamass-milter
|
||||||
|
# Tag mail without rewriting the subject or body. Skip authenticated SMTP.
|
||||||
|
OPTIONS="-m -I -- -d 127.0.0.1 -n 2 -t 15 --connect-retries=1"
|
||||||
|
SOCKET="/var/spool/postfix/spamass/spamass.sock"
|
||||||
|
SOCKETOWNER="spamass-milter:postfix"
|
||||||
|
SOCKETMODE="0660"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# /etc/default/spamd
|
||||||
|
OPTIONS="--listen=127.0.0.1 --allowed-ips=127.0.0.1 --username=debian-spamd --nouser-config --max-children=5 --timeout-child=15 --helper-home-dir=/var/lib/spamassassin"
|
||||||
+79
-3
@@ -993,6 +993,78 @@ Back up mail on the node that hosts the mailbox. The archive can be used to
|
|||||||
recover messages and folders into a newly provisioned mailbox with the same
|
recover messages and folders into a newly provisioned mailbox with the same
|
||||||
address. [Mailbox backup and restore](development.md#back-up-and-restore-a-mailbox)
|
address. [Mailbox backup and restore](development.md#back-up-and-restore-a-mailbox)
|
||||||
|
|
||||||
|
## Filter incoming mail with SpamAssassin
|
||||||
|
|
||||||
|
Install the distribution's SpamAssassin and `spamass-milter` packages on
|
||||||
|
the host where Postfix receives mail. Use the same setup for a co-located
|
||||||
|
mail service and a separate mail node. A node shared by multiple Coulobre
|
||||||
|
installations needs one filter configuration.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo apt install spamassassin spamd spamc spamass-milter
|
||||||
|
sudo adduser spamass-milter postfix
|
||||||
|
sudoedit /etc/default/spamd /etc/default/spamass-milter /etc/postfix/main.cf
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the settings from `deploy/spamassassin/spamd.default.example` and
|
||||||
|
`deploy/spamassassin/spamass-milter.default.example` in the corresponding
|
||||||
|
defaults files. The scanner listens on loopback and uses site-wide rules.
|
||||||
|
Postfix reaches the milter through a group-restricted socket inside its
|
||||||
|
queue directory.
|
||||||
|
|
||||||
|
Merge the `smtpd_milters` entry in
|
||||||
|
`deploy/spamassassin/postfix-main.cf.example` into the existing list. If a
|
||||||
|
receiving service overrides `smtpd_milters` in `master.cf`, add the entry
|
||||||
|
there too. The example skips authenticated SMTP and covers messages
|
||||||
|
received by an SMTP service configured with this milter. Deliveries from
|
||||||
|
the local `sendmail` command use Postfix's separate non-SMTP path.
|
||||||
|
[Postfix Milter setup](https://www.postfix.org/MILTER_README.html)
|
||||||
|
|
||||||
|
If Debian 13's `spamass-milter.service` is generated from
|
||||||
|
`/etc/init.d/spamass-milter`, install this drop-in so systemd tracks the
|
||||||
|
milter process.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo install -D -m 0644 deploy/spamassassin/debian-milter.service.conf \
|
||||||
|
/etc/systemd/system/spamass-milter.service.d/coulobre.conf
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo spamassassin --lint
|
||||||
|
sudo systemctl enable spamd.service spamass-milter.service
|
||||||
|
sudo systemctl restart spamd.service spamass-milter.service
|
||||||
|
sudo postfix check
|
||||||
|
sudo postfix reload
|
||||||
|
```
|
||||||
|
|
||||||
|
The example delivers scanned messages with an `X-Spam-Status` header and
|
||||||
|
preserves the subject and body. Set the tagging threshold with
|
||||||
|
`required_score` in `/etc/spamassassin/local.cf`. Restart `spamd.service`
|
||||||
|
after editing its rules. The example lets Postfix accept mail during a
|
||||||
|
milter outage and lets the milter pass mail through during a scanner
|
||||||
|
outage. Messages above the `spamc` size limit also pass through unscanned.
|
||||||
|
The per-milter fallback preserves the failure policy of any other filter.
|
||||||
|
[SpamAssassin settings](https://spamassassin.apache.org/full/4.0.x/doc/Mail_SpamAssassin_Conf.html)
|
||||||
|
|
||||||
|
On a test mail node, check delivery through SMTP to a Coulobre mailbox and
|
||||||
|
inspect the full headers over IMAP.
|
||||||
|
|
||||||
|
1. Send a normal message and look for `X-Spam-Status: No`.
|
||||||
|
2. Send the [GTUBE test message](https://spamassassin.apache.org/gtube/)
|
||||||
|
and look for `X-Spam-Status: Yes` with `GTUBE` in the matched tests.
|
||||||
|
3. Stop `spamd.service` and send another test message. Confirm it arrives
|
||||||
|
without a scanner-added status. Start the scanner and repeat with
|
||||||
|
`spamass-milter.service` stopped. Start both services after testing.
|
||||||
|
|
||||||
|
Use `spamc -d 127.0.0.1 -K` to check the scanner from the mail node. Read
|
||||||
|
scan results with `journalctl -u spamd.service -u spamass-milter.service`
|
||||||
|
and Postfix's filter connection errors with `journalctl -t postfix/smtpd`
|
||||||
|
or in the mail log.
|
||||||
|
Add `spamd` and `spamass-milter` to the mail node's
|
||||||
|
[service health checks](#monitor-local-and-remote-services) to monitor the
|
||||||
|
two units.
|
||||||
|
|
||||||
## Provision mail and DNS on separate servers
|
## Provision mail and DNS on separate servers
|
||||||
|
|
||||||
Choose one destination per service. For example, run mail locally and publish
|
Choose one destination per service. For example, run mail locally and publish
|
||||||
@@ -1066,6 +1138,8 @@ Set up [BIND9](development.md#apply-a-zone-manifest) or
|
|||||||
the corresponding [DNS socket](development.md#enable-local-dns-publishing) or
|
the corresponding [DNS socket](development.md#enable-local-dns-publishing) or
|
||||||
[mailbox socket](development.md#enable-local-mailbox-provisioning). The
|
[mailbox socket](development.md#enable-local-mailbox-provisioning). The
|
||||||
destination runs the local socket service shipped with Coulobre.
|
destination runs the local socket service shipped with Coulobre.
|
||||||
|
[Enable SpamAssassin on the mail node](#filter-incoming-mail-with-spamassassin)
|
||||||
|
for incoming spam filtering.
|
||||||
|
|
||||||
Save the panel's public key from the previous step as `panel-node.pub` on
|
Save the panel's public key from the previous step as `panel-node.pub` on
|
||||||
the destination. Create a receiver with only the socket group for that
|
the destination. Create a receiver with only the socket group for that
|
||||||
@@ -1304,9 +1378,11 @@ COULOBRE_SERVICE_HEALTH='{"panel-01":{"local":["panel","worker","scheduler","apa
|
|||||||
Choose an ID for each node using lower-case letters, numbers, and hyphens,
|
Choose an ID for each node using lower-case letters, numbers, and hyphens,
|
||||||
starting with a letter. Keep the IDs stable for the same hosts. List one
|
starting with a letter. Keep the IDs stable for the same hosts. List one
|
||||||
`local` node per panel installation and use `ssh` for each additional host.
|
`local` node per panel installation and use `ssh` for each additional host.
|
||||||
Use `bind9`, `postfix`, and `dovecot` under `local` for co-located services.
|
Use `bind9`, `postfix`, `dovecot`, `spamd`, and `spamass-milter` under
|
||||||
Remote checks accept those same three service names. The SSH client matches
|
`local` for co-located services or under `ssh` for separate nodes. Only
|
||||||
each remote node ID to a `Host` entry.
|
list the spam filter units where filtering is configured. Update the
|
||||||
|
Coulobre package on a remote node before adding its filter units. The
|
||||||
|
SSH client matches each remote node ID to a `Host` entry.
|
||||||
|
|
||||||
Install the collector with a dedicated service identity after updating the
|
Install the collector with a dedicated service identity after updating the
|
||||||
panel package.
|
panel package.
|
||||||
|
|||||||
Reference in new issue
Block a user