# Suppress images for short emails

**URL:** https://meta.discourse.org/t/suppress-images-for-short-emails/20235
**Category:** Feature
**Created:** [9월 19, 2014, 8:50오전 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235 "2014-09-19T08:50:58Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [9월 19, 2014, 8:50오전 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/1 "2014-09-19T08:50:58Z")

</div>

To prevent Discourse emails being detected as spam, we should suppress images from short emails (having text length 2800 Bytes or less).

Currently short emails with images are detected as spam by [Apache SpamAssassin](http://spamassassin.apache.org), due to [HTML\_IMAGE\_ONLY\_24](https://wiki.apache.org/spamassassin/Rules/HTML_IMAGE_ONLY_24) rule.

I sent a PR for this:

[https://github.com/discourse/discourse/pull/2805](https://github.com/discourse/discourse/pull/2805)

Any suggestion/feedback on this?

cc @sam @codinghorror @supermathie

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [9월 19, 2014, 12:03오후 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/2 "2014-09-19T12:03:57Z")

</div>

> [@techAPJ](#):
>
> Currently short emails with images are detected as spam by Apache SpamAssassin

Too strong. Short emails with HTML images is an indicator used by SA, contributing ~30% of the necessary score to be detected as spam.

The bayesian filtering is independent of this.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9월 19, 2014, 4:25오후 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/3 "2014-09-19T16:25:51Z")

</div>

The scores we were shown are

```
BAYES_95 3
HTML_IMAGE_ONLY_24 1.618
RDNS_NONE 0.793

```

Total score 5.4111

So that 30% number is right on target!

[https://wiki.apache.org/spamassassin/Rules/HTML\_IMAGE\_ONLY\_24](https://wiki.apache.org/spamassassin/Rules/HTML_IMAGE_ONLY_24)

 ![](https://global.discourse-cdn.com/meta/original/3X/c/5/c5838a48d6353da2b7c8b0c924fdedaeffe1213b.png)

---

<div class="post-metadata">

### Author: ![dfabulich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dfabulich/32/108716_2.png) [@dfabulich](https://meta.discourse.org/u/dfabulich)
#### Post date: [9월 20, 2014, 4:07오전 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/4 "2014-09-20T04:07:23Z")

</div>

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.)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9월 20, 2014, 2:30오후 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/5 "2014-09-20T14:30:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dfabulich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dfabulich/32/108716_2.png) [@dfabulich](https://meta.discourse.org/u/dfabulich)
#### Post date: [9월 20, 2014, 3:03오후 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/6 "2014-09-20T15:03:14Z")

</div>

Good point. Many emoji have a Unicode representation. Others could be replaced by their textual representation.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [9월 24, 2014, 6:37오후 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/7 "2014-09-24T18:37:18Z")

</div>

Okay, as per the feedback, I have done following [updates](https://github.com/discourse/discourse/pull/2805/files):

- Only Avatar and Emoji images will be suppressed from email
- Avatar image will be replaced with their relevant title text, e.g. ❤ will be replaced by `:heart:`
- Short email length is configurable in site settings, default will be `2800`

* * *

**Example:**

This post on forum:

![](https://global.discourse-cdn.com/meta/original/3X/4/3/43c4b1319e4c53e5684cef5449249b2f69f02674.png)

Gets rendered in email as:

![](https://global.discourse-cdn.com/meta/original/3X/c/1/c105d802f8d94fe5d7884d84fc76702f3df56fa2.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [9월 24, 2014, 11:56오후 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/8 "2014-09-24T23:56:14Z")

</div>

@techAPJ can you fix alignment for this very common case

![](https://global.discourse-cdn.com/meta/original/3X/d/8/d8c6949d57e44f02e5cfb973ebd75d4c529e9614.png)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [9월 25, 2014, 5:48오전 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/9 "2014-09-25T05:48:43Z")

</div>

Fixed:

[https://github.com/discourse/discourse/pull/2822](https://github.com/discourse/discourse/pull/2822)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9월 27, 2014, 10:18오후 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/10 "2014-09-27T22:18:26Z")

</div>

This topic was automatically closed after 3 days. New replies are no longer allowed.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [10월 1, 2014, 7:41오전 UTC](https://meta.discourse.org/t/suppress-images-for-short-emails/20235/11 "2014-10-01T07:41:14Z")

</div>

Just to confirm this is definitely working. Here’s a short email notice I just got:

 ![](https://global.discourse-cdn.com/meta/original/3X/d/e/deeabc5758439226f467257435250a090a6647e2.png) 

Notice removed avatar. Good work @techapj!
