邮件::接收器::未检测到正文错误(转发邮件)

For the past two months or so, I am continuously getting the following error on forwarding any email to a category of my discourse instance:

Incoming Email Details

Error Email::Receiver::NoBodyDetectedError

Happens when we couldn't extract a body and there were no attachments.

I have tried all three possibilities in the “forwarded emails behaviour” setting, but to no avail.

Are others facing the same? IIRC, it used to just work earlier by creating a new topic with the contents of the quoted forwarded email. Is the expected behavior for forwarded emails documented somewhere (I could not find it)?

1 个赞

Update: It is still happening. Would someone be able to take a look?

When I copy-paste the forwarded email in the text box at /admin/email/advanced-test, it seems to be parsed correctly with separation between the text body and elided header information, but I don’t understand why is the email rejected with no body error when actually received by discourse.

you need a plugin to allow these emails, so they don’t get rejected within the app UI

Hopefully the below code will work


plugin.rb

after_initialize do
  reloadable_patch do |plugin|

    class Email::Receiver

      module MailReceiverOverride
        def trim_reply_and_extract_elided(text)
          is_email_message = false
          destinations.each do |destination|
            next unless destination.is_a?(Category)
            is_email_message = true if destination.id == SiteSetting.email_tweak_category_id.to_i
          end

          if is_email_message
            return [text, ""]
          end

          return super
        end
      end

      prepend MailReceiverOverride
    end

  end
end

settings.yml

plugins:
  email_tweak_category_id:
    default: ''