A discussion on suppressing images for short emails to prevent them from being detected as spam by Apache SpamAssassin. techAPJ proposed a solution to suppress images from short emails (2800 bytes or less) and submitted a PR.
supermathie pointed out that short emails with HTML images are just one indicator used by SpamAssassin, contributing around 30% to the necessary score to be detected as spam.
codinghorror shared scores showing that the HTML_IMAGE_ONLY_24 rule contributed significantly to the spam score.
dfabulich suggested that instead of stripping all images, just suppressing the avatar image for short messages could address 80% of the problem.
codinghorror agreed but also suggested suppressing emoji, as they could trigger the Spam Assassin filters.
After feedback, techAPJ updated the PR to only suppress avatar and emoji images, replacing them with their textual representation. The update also made the short email length configurable in site settings.
The changes were tested and confirmed to be working by codinghorror.
This implementation strips images out using a regex. That means that if the post itself includes images, the images will be simply missing from the email, which could be confusing to the email recipient.
IME, the vast majority of emails I receive from my Discourse instance include only the avatar image; I bet 80% of the problem would be addressed by just suppressing the avatar for short messages. Then, if someone does send out a post whose content is nothing but an image, just that email may be (correctly!) flagged with HTML_IMAGE_ONLY_24.
(Indeed, the post itself might be actual spam posted by a spammer, so just by suppressing the avatar, we’d allow the spam catcher to do its own thing.)
I like the advice of narrowing the regex to suppress just the avatar images, however, we should also suppress emoji. A short message with an emoji will trigger this just as badly. And emoji aren’t so important that they should be allowed to trigger the Spam Assassin filters for short HTML with image.