[GH-ISSUE #440] Spam rules not displayed in web interface #284

Closed
opened 2026-03-15 13:40:49 +03:00 by kerem · 11 comments
Owner

Originally created by @dani on GitHub (Feb 12, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/440

I just enabled spamassassin integration on mailpit 1.22.2 (I'm using a Docker image very similar to yours for spamassassin, based on alpine, version 4.0.1). Everything seems to work, except triggered rules are not displayed in mailpit interface, I only have the global score displayed

Image

While in spamassassin's log, I can see the triggered tests, eg

2025-02-12 10:20:44.000 Feb 12 11:20:44.641 [39] info: spamd: connection from localhost [127.0.0.1]:37814 to port 783, fd 5
2025-02-12 10:20:44.000 Feb 12 11:20:44.642 [39] info: spamd: checking message <hardening-front/1538/1739355631@taiga.test.com> for (unknown):783
2025-02-12 10:20:44.000 Feb 12 11:20:44.713 [39] info: spamd: clean message (-0.2/5.0) for (unknown):783 in 0.1 seconds, 19057 bytes.
2025-02-12 10:20:44.000 Feb 12 11:20:44.713 [39] info: spamd: result: .  0 - ALL_TRUSTED,DKIM_ADSP_NXDOMAIN,HTML_MESSAGE scantime=0.1,size=19057,user=(unknown),uid=783,required_score=5.0,rhost=localhost,raddr=127.0.0.1,rport=37814,mid=<hardening-front/1538/1739355631@taiga.test.com>,autolearn=no autolearn_force=no
2025-02-12 10:20:44.000 Feb 12 11:20:44.725 [37] info: prefork: child states: II

Same if I add the GTUBE string to trigger a very high spam score. Mailpit does display it's a spam with a score of 999.7/5, but still no rules detail

Originally created by @dani on GitHub (Feb 12, 2025). Original GitHub issue: https://github.com/axllent/mailpit/issues/440 I just enabled spamassassin integration on mailpit 1.22.2 (I'm using a Docker image very similar to yours for spamassassin, based on alpine, version 4.0.1). Everything seems to work, except triggered rules are not displayed in mailpit interface, I only have the global score displayed ![Image](https://github.com/user-attachments/assets/367ccfcc-4378-466d-9575-4c14f1d69785) While in spamassassin's log, I can see the triggered tests, eg ``` 2025-02-12 10:20:44.000 Feb 12 11:20:44.641 [39] info: spamd: connection from localhost [127.0.0.1]:37814 to port 783, fd 5 2025-02-12 10:20:44.000 Feb 12 11:20:44.642 [39] info: spamd: checking message <hardening-front/1538/1739355631@taiga.test.com> for (unknown):783 2025-02-12 10:20:44.000 Feb 12 11:20:44.713 [39] info: spamd: clean message (-0.2/5.0) for (unknown):783 in 0.1 seconds, 19057 bytes. 2025-02-12 10:20:44.000 Feb 12 11:20:44.713 [39] info: spamd: result: . 0 - ALL_TRUSTED,DKIM_ADSP_NXDOMAIN,HTML_MESSAGE scantime=0.1,size=19057,user=(unknown),uid=783,required_score=5.0,rhost=localhost,raddr=127.0.0.1,rport=37814,mid=<hardening-front/1538/1739355631@taiga.test.com>,autolearn=no autolearn_force=no 2025-02-12 10:20:44.000 Feb 12 11:20:44.725 [37] info: prefork: child states: II ``` Same if I add the GTUBE string to trigger a very high spam score. Mailpit does display it's a spam with a score of 999.7/5, but still no rules detail
kerem closed this issue 2026-03-15 13:40:55 +03:00
Author
Owner

@dani commented on GitHub (Feb 12, 2025):

Calls to the sa-check endpoint returns an empty rule list, eg

{"IsSpam":true,"Error":"","Score":999.7,"Rules":[]}
<!-- gh-comment-id:2653296768 --> @dani commented on GitHub (Feb 12, 2025): Calls to the sa-check endpoint returns an empty rule list, eg ``` {"IsSpam":true,"Error":"","Score":999.7,"Rules":[]}
Author
Owner

@axllent commented on GitHub (Feb 12, 2025):

I think this is because you're using spamassassin v4.... From memory V3 is currently supported. Could you please try with the axllent/spamassassin docker image and confirm that works?

It's not that I don't want to support v4, it's just that it was not included in any limited distribution I tested back then. If alpine now does support v4, then I have some work to do...

<!-- gh-comment-id:2654517447 --> @axllent commented on GitHub (Feb 12, 2025): I think this is because you're using spamassassin v4.... From memory V3 is currently supported. Could you please try with the axllent/spamassassin docker image and confirm that works? It's not that I don't want to support v4, it's just that it was not included in any limited distribution I tested back then. If alpine now does support v4, then I have some work to do...
Author
Owner

@dani commented on GitHub (Feb 12, 2025):

Just tried with your image (so spamassassin 3.4), with the same result. No rule displayed in the web interface, even if there was a rule matched

2025-02-12 21:25:35.000 Feb 12 22:25:35.741 [248] info: spamd: result: . -1 - ALL_TRUSTED scantime=0.0,size=549,user=(unknown),uid=65534,required_score=5.0,rhost=127.0.0.1,raddr=127.0.0.1,rport=53700,mid=<173939553259.314.5042666987043224683@taiga>,autolearn=unavailable autolearn_force=no
<!-- gh-comment-id:2654893548 --> @dani commented on GitHub (Feb 12, 2025): Just tried with your image (so spamassassin 3.4), with the same result. No rule displayed in the web interface, even if there was a rule matched ``` 2025-02-12 21:25:35.000 Feb 12 22:25:35.741 [248] info: spamd: result: . -1 - ALL_TRUSTED scantime=0.0,size=549,user=(unknown),uid=65534,required_score=5.0,rhost=127.0.0.1,raddr=127.0.0.1,rport=53700,mid=<173939553259.314.5042666987043224683@taiga>,autolearn=unavailable autolearn_force=no ```
Author
Owner

@axllent commented on GitHub (Feb 13, 2025):

This is really strange. I have tested on both the current (my) spanassassin docker image (spamassassin v3) as well as a locally build spamassassin v4 (alpine version, thanks for the heads-up that v4 is finally available), and they both work as expected with Mailpit. The good news is that Mailpit appears to work with both versions! The bad news is I cannot replicate your error.

Below is a screenshot of SA 4.0.1

Image

I get the rules returned in the response too:

{"IsSpam":false,"Error":"","Score":1.2,"Rules":[{"Score":0,"Name":"HTML_MESSAGE","Description":"BODY: HTML included in message"},{"Score":2.2,"Name":"HTML_IMAGE_ONLY_32","Description":"BODY: HTML: images with 2800-3200 bytes of words"},{"Score":-1,"Name":"MAILING_LIST_MULTI","Description":"Multiple indicators imply a widely-seen list manager"}]}

I then just did the GTUBE test and get:

Image

{"IsSpam":true,"Error":"","Score":1000,"Rules":[{"Score":-0,"Name":"NO_RECEIVED","Description":"Informational: message has no Received headers"},{"Score":-0,"Name":"NO_RELAYS","Description":"Informational: message was not relayed via SMTP"},{"Score":1000,"Name":"GTUBE","Description":"BODY: Generic Test for Unsolicited Bulk Email"},{"Score":0,"Name":"HTML_MESSAGE","Description":"BODY: HTML included in message"}]}

Could it be that your SpamAssassin container does not have network connectivity, and therefore cannot download any rules? Could you try manually run sa-update -v within the SA container and see if you get any errors?

<!-- gh-comment-id:2655378811 --> @axllent commented on GitHub (Feb 13, 2025): This is really strange. I have tested on both the current (my) spanassassin docker image (spamassassin v3) as well as a locally build spamassassin v4 (alpine version, thanks for the heads-up that v4 is finally available), and they both work as expected with Mailpit. The good news is that Mailpit appears to work with both versions! The bad news is I cannot replicate your error. Below is a screenshot of SA 4.0.1 ![Image](https://github.com/user-attachments/assets/c6ca6da6-f5a1-4f0b-9210-58e11368c1b8) I get the rules returned in the response too: ```json {"IsSpam":false,"Error":"","Score":1.2,"Rules":[{"Score":0,"Name":"HTML_MESSAGE","Description":"BODY: HTML included in message"},{"Score":2.2,"Name":"HTML_IMAGE_ONLY_32","Description":"BODY: HTML: images with 2800-3200 bytes of words"},{"Score":-1,"Name":"MAILING_LIST_MULTI","Description":"Multiple indicators imply a widely-seen list manager"}]} ``` I then just did the [GTUBE](https://spamassassin.apache.org/gtube/) test and get: ![Image](https://github.com/user-attachments/assets/0a0bd6e3-03d2-4951-bc62-058b504d8ff7) ```json {"IsSpam":true,"Error":"","Score":1000,"Rules":[{"Score":-0,"Name":"NO_RECEIVED","Description":"Informational: message has no Received headers"},{"Score":-0,"Name":"NO_RELAYS","Description":"Informational: message was not relayed via SMTP"},{"Score":1000,"Name":"GTUBE","Description":"BODY: Generic Test for Unsolicited Bulk Email"},{"Score":0,"Name":"HTML_MESSAGE","Description":"BODY: HTML included in message"}]} ``` Could it be that your SpamAssassin container does not have network connectivity, and therefore cannot download any rules? Could you try manually run `sa-update -v` within the SA container and see if you get any errors?
Author
Owner

@dani commented on GitHub (Feb 13, 2025):

Could it be that your SpamAssassin container does not have network connectivity, and therefore cannot download any rules? Could you try manually run sa-update -v within the SA container and see if you get any errors?

I don't think so. sa-update runs fine. I even bundled rules in my image just to be sure (but anyway, spamd refuses to start if there are no rules at all). Plus, my spamd logs show that rules are triggered. I'll try to debug this

<!-- gh-comment-id:2655833038 --> @dani commented on GitHub (Feb 13, 2025): > Could it be that your SpamAssassin container does not have network connectivity, and therefore cannot download any rules? Could you try manually run `sa-update -v` within the SA container and see if you get any errors? I don't think so. sa-update runs fine. I even bundled rules in my image just to be sure (but anyway, spamd refuses to start if there are no rules at all). Plus, my spamd logs show that rules are triggered. I'll try to debug this
Author
Owner

@axllent commented on GitHub (Feb 13, 2025):

Fair point. I'm completely out of ideas at this stage, all I know is it "just works" for me, and seemingly all others too, so there must be some unique reason yours is not working. I look forward to your findings.

<!-- gh-comment-id:2655876050 --> @axllent commented on GitHub (Feb 13, 2025): Fair point. I'm completely out of ideas at this stage, all I know is it "just works" for me, and seemingly all others too, so there must be some unique reason yours is not working. I look forward to your findings.
Author
Owner

@dani commented on GitHub (Feb 13, 2025):

Are the rules details supposed to be stored in the SQLite DB ? Or is spamd supposed to alter the headers of the email and mailpit read them back from there ?

<!-- gh-comment-id:2656118592 --> @dani commented on GitHub (Feb 13, 2025): Are the rules details supposed to be stored in the SQLite DB ? Or is spamd supposed to alter the headers of the email and mailpit read them back from there ?
Author
Owner

@axllent commented on GitHub (Feb 13, 2025):

They come from spamassassin. Your message gets pushed to SA and it returns the response to Mailpit. Mailpit then returns a formatted response to the browser.

Nothing in the email itself is modified.

<!-- gh-comment-id:2656208617 --> @axllent commented on GitHub (Feb 13, 2025): They come from spamassassin. Your message gets pushed to SA and it returns the response to Mailpit. Mailpit then returns a formatted response to the browser. Nothing in the email itself is modified.
Author
Owner

@dani commented on GitHub (Feb 13, 2025):

so mailpit query spamassassin each time I open the web interface, for every mail that I open ? It doesn't persist SA result anywhere ?

<!-- gh-comment-id:2656260022 --> @dani commented on GitHub (Feb 13, 2025): so mailpit query spamassassin each time I open the web interface, for every mail that I open ? It doesn't persist SA result anywhere ?
Author
Owner

@dani commented on GitHub (Feb 13, 2025):

OK got it. The problem is because my spamassassin container was started with env var LANG=fr_FR.utf8. So it breaks spamassassin output parsing here
Started with LANG=C and everything is working as expected

<!-- gh-comment-id:2656420990 --> @dani commented on GitHub (Feb 13, 2025): OK got it. The problem is because my spamassassin container was started with env var LANG=fr_FR.utf8. So it breaks spamassassin output parsing [here](https://github.com/axllent/mailpit/blob/develop/internal/spamassassin/spamc/spamc.go#L200) Started with LANG=C and everything is working as expected
Author
Owner

@axllent commented on GitHub (Feb 14, 2025):

Oh that is interesting, I hadn't considered the spamassassin would ever be run using a different locale, nor that the response from spamd would be affected. It makes sense I guess, as the way the spamc client communicated with the spamd is basically over telnet. The entire response is parsed in a very horrible / old-fashioned way compared to modern day methods (eg: JSON). If a locale change impacts the data returned, then it makes sense that Mailpit will not be able to parse the full response.

I'm glad you found the cause!

<!-- gh-comment-id:2658110929 --> @axllent commented on GitHub (Feb 14, 2025): Oh that is interesting, I hadn't considered the spamassassin would ever be run using a different locale, nor that the response from spamd would be affected. It makes sense I guess, as the way the spamc client communicated with the spamd is basically over telnet. The entire response is parsed in a very horrible / old-fashioned way compared to modern day methods (eg: JSON). If a locale change impacts the data returned, then it makes sense that Mailpit will not be able to parse the full response. I'm glad you found the cause!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#284
No description provided.