`enable_forwarded_emails` doesn't behave like conventional email forwarding

enable_forwarded_emails is a great feature for bringing existing conversations into Discourse, but for users who approach Discourse with a “Mailman-mind” - as many users on our instance do - this feature just doesn’t do what they’re expecting it to.

Within every email client I’ve used, forwarding an email intentionally excludes the original email address from the forward, and subsequent replies. Whereas with this feature, that original email address is included in the created post and subsequent replies.

If this feature isn’t enabled, then Discourse strips the actual forwarded email, which also doesn’t work for us.

My thought is there should be an alternative feature which doesn’t strip the forwarded email and posts it like so:

Thought you all should see this:

---------- Forwarded message ---------
From: Example Person <person@example.com>
Date: Wed, 13 Mar 2019 at 15:11
Subject: An email to be forwarded
To: <some_discourse_user@example.com>

The original email

This would be a lot like the result of the always_show_trimmed_content setting, but with the trimmed content automatically expanded (and therefore visible in email notifications).

@zogstrip what are your thoughts here?

With just a little bit of rejigging of the code you’ve already written for enable_forwarded_emails I think what I want to see would be relatively easy - and that’s rejigging I’m happy to do.

Perhaps the solution here is to create a new multiple-choice site setting, something like:

forwarded_emails_behaviour:

  • hide (default)
  • show (the behaviour I’m advocating for here)
  • create_replies (the existing enable_forwarded_emails behaviour)
9 Likes

I like that :+1:

PR at will :wink:

5 Likes

It took me a little while, but here’s the PR:

https://github.com/discourse/discourse/pull/7935

8 Likes

Currently, this setting has these options available:

So I suppose the “show” option became “quote”?

Also, I don’t quite get why the other option is called “create replies”. What does it mean? (or: what does it do?)

Yep, as both other options “show” the forwarded email, but this one quotes in in the original post.

What it says on the :canned_food:! It’ll attempt to parse the forwarded email, then create a staged user from the original sender of the forwarded email, and post the forwarded email as the original topic and then any text the forwarder includes as a reply to that topic (at least that’s the way round I remember it working).

3 Likes

Aah, now I get it. It’s the text that the forwarder includes that becomes the reply! But that’s exactly one reply. Why does it say create replies?

Another reason why the terminology is somewhat confusing: both “hide” and “quote” refer to the forwarded text but “create replies” refers to the forwarders commentary om the forwarded text. So perhaps these options could be clarified somehow by saying

  • hide forwarded email
  • quote forwarded email
  • post forwarded mail with replies

As I write, I’m wondering whether this third option is really how it works. I don’t think it ever behaved like that for us but then again we don’t have a lot of forwarded mails, so I’m not sure. Does it even make sense to post the forwarders comment as a reply? Shouldn’t it somehow be made clear that the forwarded email was posted by the forwarder? This is not at all clear when you have the forwarder apparently reply to it.

3 Likes

So I’m using the quote setting and it definitely doesn’t work as described. Maybe I’m still misunderstanding the intended behaviour but this seems pretty clear:

and this is not what I’m getting. So let me be mote precise in what I’m getting: someone forwarded an email starting with a short note like “Look at this” followed by the forwarded email. The forwarded email included text as well as two pdf files as attachments. The post shown on the forum looked like this:

Look at this!
Cheers,
Sara

document1.pdf
document2.pdf

That was all.

So the forwarded email was completely stripped with the exception of the file attachments. I was able to recover it manually and it even started with ---------- Forwarded message --------- so identifying it could not have been easier…

Hmm, I wonder if the attachments are messing things up here. This is how they (correctly) appear for me: Fwd: email to site-feedback.support - Support - Mozilla Discourse Dev

3 Likes

Okay, that looks just like I’d expect it. Good to see that it works at least under certain circumstances. But did your email include an attachment? If not, it seems plausible that discourse is confused by (certain?) attachments.

I’m still having issues with forwarded emails not being displayed. Since I do have at least one email with attachments that was correctly rendered, my guess is now that it has to do with whether the person forwarding the email added something to the email or not. From what I can see, emails that were forwarded without adding any text above the forwarded email were rendered correctly but if the forwarder added something like “FYI”, only the attachments are included in the post but not the text of the forwarded email.

In other words, this example still doesn’t work (because it includes “Thought you all should see this:”):

Instead of the above result, this email would be rendered as:

Thought you all should see this:

And nothing else.

Could someone confirm whether this problem is specific to my instance or whether it exists also elsewhere?

Please check emails with an attachment in particular (e.g. a pdf file) as it is possible that the problem only occurs when text is added AND there is an attachment.

I also am still confused what these different labels/features do – trying to set up incoming email to use with the Tickets Plugin :tickets: but getting inconsistent behavior.

I feel like the default behavior should be that whatever gets forwarded in becomes a post by the (staged or regular user) that created the message. The reason it’s getting forwarded seems to most often be that someone who got the message felt it would be better addressed on Discourse, so that topic seems most appropriate to be started by the email’s author, not the forwarder.

(But maybe my use cases are actually edge cases…)

It should work that way when you set enable_forwarded_emails to create_replies. The forwarded email will be the first post and it creates a reply if the forwarder wrote some text. Otherwise it creates a small action post, so that it is clear who forwarded the first post.

2 Likes

OK, so I think I’m finally learning –

If create_replies is the chosen value for the forwarded emails behaviour site setting, then the original message becomes the opening post in the topic, and anything written in the email above the forwarded message, becomes a reply to the topic below the 3rd party message. :confused:

Q: Do any of the other values of this site setting – namely, hide or quote – just (only) process the original 3rd party message and nothing more?

I am wondering if the attempt to split out these “create replies” might be the cause of some weird errors I’ve been seeing when sending things in from a Microsoft Outlook client.

PS: I wonder, might this setting be worth a FAQ/howto entry to be linked from the description text below the site setting? It might just be me but I have rarely been so confused with a Discourse setting over the past 7 years. Or maybe I just need more :coffee: :smile:

No. You will get a small action post when there’s no text before the forwarded message.

I believe this feature is still marked as experimental and there’s a good reason for it. Emails are usually forwarded inline. That makes it quite hard to extract the forwarded email, because each client forwards the original email headers differently. Some even hide the email address of the original From header or use localized headers.

It should work a lot better when emails are forwarded as attachment instead of inline (I’m 99% sure that Discourse supports this).

1 Like

I would agree that would be a much cleaner way to ensure correct processing. I wonder why I can’t get Discourse to process the attachments when I do. (The content of the forwarded attachment comes through in the raw content tagged to the post, but only the ‘commentary’ is rendered, not the forwarded original. Again, at least for MS Outlook; I’ll have to try some other clients.)

1 Like

Maybe it’s not implemented after all? I haven’t looked at the code yet. :blush:
Please report back if it works with other clients.

1 Like

Inline forwarded messages are getting trimmed away, with both quote and create_replies modes enabled.

Any suggestions?

Original message (some headers removed):

From: Jeffrey Lastname <jeff@myemail.us>
To: test-cat@example.org
Subject: Fwd: Thank you for your support!
X-Mailer: MailMate (1.14r5745)
Content-Type: text/plain; format=flowed

Some really long sample text.

Forwarded message:

> From: Donations Team <giving@example2.org>
> To: jeff@myemail.us
> Subject: Thank you for your support!
>
> Dear Jeffrey,
>
> Our heartfelt thanks for your donation to Example Project, 
> especially now. Together we will write the future.

Message in the forum board (same for both modes):

Some really long sample text.

Forwarded message:

Forwarding the message as an attachment doesn’t seem to work either. eml attachments are rejected. If eml attachments are authorized, then in “create_replies” mode, it attaches the eml and the forum visitor has the option to download it.

Is there a way to get email notifications to show the forwarded email message?

With

  • forwarded_emails_behaviour set to “quote” and

  • always_show_trimmed_content set on,

our discourse website (2.6.0, stable) shows the forwarded email just as one would wish, once I click the three dots:

However, the email notification omits the forwarded email entirely:
image

1 Like