axllent / mailpit

An email and SMTP testing tool with API for developers
https://mailpit.axllent.org
MIT License
6.17k stars 153 forks source link

Issues with SpamAssassin integration #361

Closed brenc closed 2 months ago

brenc commented 2 months ago

I'm setting up mailpit today (which is awesome) but I can't get SpamAssassin integration to work. First I set MP_ENABLE_SPAMASSASSIN: postmark and I can see the log line [spamassassin] enabled via postmark but in the UI there is no Spam Analysis tab on my test emails. No logs of an attempt either when sending test emails with verbose logging on.

Then I tried setting up the Docker container and using it locally. Here's my full compose file:

services:
  mailpit:
    container_name: mailpit
    depends_on:
      - spamassassin
    environment:
      MP_MAX_MESSAGES: 5000
      MP_DATABASE: /data/mailpit.db
      MP_ENABLE_SPAMASSASSIN: spamassassin:783
      MP_SMTP_AUTH_ACCEPT_ANY: 1
      MP_SMTP_AUTH_ALLOW_INSECURE: 1
      MP_VERBOSE: 1
    image: axllent/mailpit
    ports:
      - 8350:8025
      - 8351:1025
    restart: unless-stopped
    volumes:
      - ./data:/data

  spamassassin:
    image: axllent/spamassassin
    container_name: spamassassin
    ports:
      - 8352:783
    restart: unless-stopped

mailpit logs show:

...
mailpit       | time="2024/09/12 15:58:27" level=info msg="[spamassassin] enabled via spamassassin:783"
mailpit       | time="2024/09/12 15:58:27" level=warning msg="[spamassassin] ping: dial tcp 172.22.0.2:783: connect: connection refused"
...
spamassassin  | Sep 12 15:58:29.302 [11] info: spamd: server started on IO::Socket::IP [::]:783, IO::Socket::IP [0.0.0.0]:783 (running version 3.4.6)

It takes a few seconds for SpamAssassin to open the port. I can connect to it via the mailpit container using nc after it starts. It appears mailpit attempts to connect one time on startup (before the port opens up) then gives up. It doesn't attempt to use the local SpamAssassin instance again (or maybe I'm missing something obvious).

I'm sending test emails with bun script + nodemailer if that makes any difference.

brenc commented 2 months ago

I'm not sure what I did but postmark and local SpamAssassin are both working now. This must've been on my end.

axllent commented 2 months ago

Mailpit will try to connect to the spamassassin server on startup, and in this case Mailpit is starting much faster than spamassassin so you're getting the warning. Despite the error however, it should not have prevented the integration from working once it was all loaded, so I assume you simply hadn't reloaded your browser after enabling spamassassin 🤷‍♂️

Either way, I'm glad it's working 👍