This site sends emails with the wrong Content-Type (for the Community Blog integration)

I do not see a setting in my profile to adjust this, but emails I get from posts come to my inbox formatted as HTML in the message body but contain

Content-Type: text/plain; charset=UTF-8

In the header. This causes display problems on my end and it would be nice if Discourse could send either plain text email or the correct Content-Type identifier. In this case, text/html.

Has anyone else seen this?

Yes, repeatedly,

Afaik, Discourse sends each mail with two content types.

You can see it in the original text of the e-mail, there is a text version AND HTML version of the same content.

.... common headers

Content-Type: multipart/alternative; boundary="--==_mimepart_62e4dbde643d4_8e74d3d3c103544d3"

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

.... text content

Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html><html xmlns=3D"" lang=3D"en" xml=

.... rest of the html content


And my assumption is that the mail client supposed to choose which part to display and then skip the other part.

Can you check that both entries of the “Content-type” header are present in your mail?

So things appear a bit more complicated. The emails I get for this thread do display correctly, but larger announcements do not display correctly.

I have confirmed that both types of messages send both text/plain and text/html formats, but the ordering is not the same. Because of how I had .muttrc configured, the project announcement emails were favoring text/plain and it looked wrong. I have fixed my .muttrc and things are fine now.

That said, the text/plain variant of these messages looks completely wrong. It’s HTML markup but the content type is set to text/plain. If you view the text/html version it is basically the same but you can pass it through a MIME type handler.

I see what you mean now. And I think this is due to announcement posts being created not on Discourse itself, but rather through the integration with the Community Blog (specifically #news:commblog tag).

When you write something on Discourse, you write it in markdown-like text format and then Discourse engine converts it for HTML and plain text versions in the mail, which works nicely.

But when it fetches the article from a Community Blog, the source of the data is already in HTML. So it posts it as is into the text variant of the article.

@mattdm do you think there is a way to tweak the integration so it creates a proper text variant?

1 Like

Yeah, I’ll look into it.