postalserver / postal

📮 A fully featured open source mail delivery platform for incoming & outgoing e-mail
https://postalserver.io
MIT License
14.68k stars 1.04k forks source link

Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8 #229

Open LaurensN opened 7 years ago

LaurensN commented 7 years ago
[2017-06-12T12:35:13.472] FATAL -- : ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
[2017-06-12T12:35:13.472] FATAL -- :     15:         or the e-mail didn't include a plain text part.
    16:   - else
    17:     %pre.codeBlock= @message.plain_body
[2017-06-12T12:35:13.472] FATAL -- :
[2017-06-12T12:35:13.472] FATAL -- : app/views/messages/plain.html.haml:18:in `_app_views_messages_plain_html_haml__809546143829012049_70075317594600'

The e-mail contains a body / text part.

I can't find the character that causes the issue in the raw EML download.

Possible solution to force encoding ?

willpower232 commented 7 years ago

which programming language/client are you using?

LaurensN commented 7 years ago

Hi @willpower232,

I have no idea which e-mail client sent the e-mail to our Postal server (it seems like it was an auto-reply). I'll investigate further ASAP.

LaurensN commented 7 years ago

From the Postal headers tab:

X-Postal-Spam: no
X-Postal-Spam-Threshold: 5.0
X-Postal-Spam-Score: 0.0
X-Postal-Threat: no
Received: from xxxx by xxxx with SMTP; Mon, 12 Jun 2017 10:32:37 +0000
Received: from mail by xxxx with local (Exim 4.80)
    id xxxx
    for xxxx; Mon, 12 Jun 2017 12:32:36 +0200
From: xxxx
To: xxxx
Subject: xxxx
In-Reply-To: <xxxx>
References: <xxxx>
Auto-Submitted: auto-replied
Message-Id: <xxxx>
Date: Mon, 12 Jun 2017 12:32:36 +0200

The only "special" character in the e-mail body is 'ö'.

catphish commented 7 years ago

Looking at those headers, it appears this email has no Content-Type or Content-Encoding headers to indicate that it is not an ASCII email. It therefore should not contain any non-ASCII characters at all. This email was therefore probably generated by a broken email server.

We often find that emails with invalid encoding trigger errors such as the one you are seeing. We will add some code to detect this error and process the email as well as possible, stripping out the invalid non-ASCII characters.

dtrckd commented 2 years ago

I also got a similar error.

From the web interface:

Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8
Support Ref: J-PH[...]

And from the docker logs

[9] [2022-06-28T16:50:32.104] INFO -- : Completed 500 Internal Server Error in 39ms (ActiveRecord: 5.3ms)
[9] [2022-06-28T16:50:32.105] FATAL -- :   
[9] [2022-06-28T16:50:32.105] FATAL -- : ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
[9] [2022-06-28T16:50:32.106] FATAL -- :     15:         or the e-mail didn't include a plain text part.
    16:   - else
    17:     %pre.codeBlock= @message.plain_body
[9] [2022-06-28T16:50:32.106] FATAL -- :   
[9] [2022-06-28T16:50:32.106] FATAL -- : app/views/messages/plain.html.haml:18:in `_app_views_messages_plain_html_haml__250971508879007162_70223690379740'

I am not sure about the undefined character as the email is a really plain text message. Could not reproduce as for now.

usr-h commented 1 year ago

missing meta utf-8 in raw_html in 2.1.2 ver. exist in 2.1.4 not exist