# Rejected mails are unreadable

**URL:** https://meta.discourse.org/t/rejected-mails-are-unreadable/392868
**Category:** Bug
**Tags:** email
**Created:** [January 7, 2026, 12:09pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868 "2026-01-07T12:09:19Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [January 7, 2026, 12:09pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/1 "2026-01-07T12:09:19Z")

</div>

When I check my self-hosted site’s `/admin/email-logs/rejected`, I find that rejected mails have their body like this:

 ![图片](https://global.discourse-cdn.com/meta/original/4X/7/0/2/7022ee48004efb062bcd76de0701b5091ce6d50a.png)

The correct mail body starts with `谢谢` in UTF-8 (the full body is much longer), and the damaged text is `m6Mtyx7x7j+rjuVupyY=` in base64.

The mails in the database are already in this damaged state. Comparing that one with the one from the mail server, I find that the mail was rewritten, and I suspect that the email cleaner module scrambled the mail. (But I don’t have enough Ruby knowledge to understand its unique string encoding feature.)

---

<div class="post-metadata">

### Author: ![ToddZ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toddz/32/328350_2.png) [@ToddZ](https://meta.discourse.org/u/ToddZ)
#### Post date: [January 7, 2026, 7:06pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/2 "2026-01-07T19:06:52Z")

</div>

Any chance these messages come from an Exchange server..?:

> [@Body of message in /admin/email-logs/rejected is sometimes displayed as gobbledegook](https://meta.discourse.org/t/body-of-message-in-admin-email-logs-rejected-is-sometimes-displayed-as-gobbledegook/387320/4):
>
> Are these messages sent from Exchange? I ask because I’m familiar with this problem and 100% of the time I’ve seen it, Exchange was the sender and the culprit. My guess is that it’s erroneously sending out an opaque reference to an internal data store via SMTP. In the cases where it’s been solved, the sender did something to fix it.

---

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [January 8, 2026, 2:08am UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/3 "2026-01-08T02:08:06Z")

</div>

No. They come from Tencent and Netease. The original mail (I kept it on the mail server to investigate this issue) has no issue with either mutt or Ruby’s Mail lib.

---

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [January 18, 2026, 5:10pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/4 "2026-01-18T17:10:12Z")

</div>

I recently got a rejected email from an Exchange server, and on the contrary it didn’t have this issue.

---

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [February 2, 2026, 6:24am UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/5 "2026-02-02T06:24:10Z")

</div>

I got it. The `part` of a `Mail` has the correct `charset` information but somehow its `body` doesn’t get it and treat the bytes as `ASCII-8BIT`.

```plaintext
sed -i 's/part.body.decoded/part.body.decoded.force_encoding(part.charset || "utf-8")/' /var/www/discourse/lib/email/cleaner.rb

```

---

<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: [February 4, 2026, 2:55pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/6 "2026-02-04T14:55:26Z")

</div>

> [@lilydjwg](#):
>
> The mails in the database are already in this damaged state.

I recently fixed this problem with:

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

> [@lilydjwg](#):
>
> The `part` of a `Mail` has the correct `charset` information but somehow its `body` doesn’t get it and treat the bytes as `ASCII-8BIT`.

Is this email (assuming it’s one that did _not_ get mangled by Discourse) something you can pass to me so that we can investigate further and possibly use it as a test case?

---

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [February 4, 2026, 3:06pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/7 "2026-02-04T15:06:39Z")

</div>

I’ve created a stripped-down version of the mail that should exhibit the issue (checked at `irb`) but without anything private:

[issuemail.txt](https://meta.discourse.org/uploads/short-url/dg0Ey8bEa5M1jWvExcVPRViRWiU.txt) (857 Bytes)

---

<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: [February 4, 2026, 4:25pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/8 "2026-02-04T16:25:01Z")

</div>

Does the email you’re talking about (and this example) still exhibit problems after updating beyond the change I linked?

---

<div class="post-metadata">

### Author: ![lilydjwg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilydjwg/32/515838_2.png) [@lilydjwg](https://meta.discourse.org/u/lilydjwg)
#### Post date: [February 5, 2026, 7:39am UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/9 "2026-02-05T07:39:07Z")

</div>

No, it has been fixed. Thank you.

---

<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: [February 5, 2026, 10:37pm UTC](https://meta.discourse.org/t/rejected-mails-are-unreadable/392868/10 "2026-02-05T22:37:27Z")

</div>


