Unexplained Email::Receiver::InvalidPost errors

Similar to Mirrored mailing list is rejecting registered forum users

It doesn’t appear to be. The referenced topic seems to be a permission problem brought on by incorrect configuration.

1 Like

My bad, apologies for the disruption.

I have proposed a fix for the problem I found, but from everything I’ve found so far the component that was performing the mangling only affects the saved record and doesn’t affect the incoming mail during processing.

I’m reasonably confident the source of the trouble must be something else, but I don’t yet know what it might be.

1 Like

Seeing that this change was merged, I upgraded our Discourse instance today and will keep an eye on the email rejected logs in the upcoming days.

1 Like

Already since the upgrade, three new InvalidPost errors were logged, but the rejection details are different: all three errors show the correct message body (where before the mailing list signature was shown) and the rejection reason is now Access Denied.

That’s some improvement at least.

Does the reason for the error stick with the user?

Are you sure the error is incorrect? Does the user have permission to post in the category? Is the user active?

Offhand, the reason doesn’t seem to stick: the account is active, not suspended nor silenced. However I noticed the account is not “staged”, which is the case for most of the accounts whose mailing list posts do end up in Discourse. All of the posts from non-staged users are from members of the moderation team.

Our mailing list mirror category was initially set up using this guide: Mirroring a read-only mailing list in Discourse

However, I just reviewed the configured permissions on the category and it seems like our moderators group was added, and `everyone` was given `reply` permissions.

I’ve removed these extra permissions and left only `everyone` with the `see` permission. Perhaps these “extra” permissions are interfering with the way Discourse handles these special “mailing list mirror” categories?

The fact that the user is not staged might be the problem. Staged users are not checked to see if they have permission to post in the category, but registered users are. So, if the user is not in a group that has permission to reply to topics in the category, their reply will be rejected because they do not have permission. The same applies to new topics and the ‘create’ permission.

There is a topic about this problem here: Category not accepting "anonymous email" from known users

1 Like

However, I just reviewed the configured permissions on the category and it seems like our moderators group was added, and `everyone` was given `reply` permissions.

I’ve removed these extra permissions and left only `everyone` with the `see` permission. Perhaps these “extra” permissions are interfering with the way Discourse handles these special “mailing list mirror” categories?

Actually, scratch that, I must have been looking at another category, because the permissions for the mailing list mirror category are as expected: only `everyone` has the `see` permission. That said, my observation that posts from non-moderator, non-staged users seem to consistently get rejected.

This explanation definitely makes sense based on what I’m seeing, but if it’s the case this is definitely unexpected and confusing behavior: senders who post to the mirrored mailing list but happen to already have an account on Discourse with the associated email address should definitely be allowed to post to categories where the “This category mirrors a mailing list” setting is enabled.

1 Like

What would be amazing is if Discourse were able to persuade/pay someone on the Mailman team (or someone similar) to improve how Discourse does emails.

1 Like

We have tests that ensure Discourse can receive mail for read-only categories that mirror a mailing list:

To support that, posts sent to mailing list mirrors bypass some checks:

    def create_post(options = {})
      …
      if sent_to_mailinglist_mirror?
        options[:skip_validations] = true
        options[:skip_guardian] = true
      else
        options[:email_spam] = is_spam?
        options[:first_post_checks] = true if is_spam?
        options[:email_auth_res_action] = auth_res_action
      end
    def sent_to_mailinglist_mirror?
      @sent_to_mailinglist_mirror ||=
        begin
          destinations.each do |destination|
            return true if destination.is_a?(Category) && destination.mailinglist_mirror?
          end

          false
        end
    end

at a guess, something to do with your setup might create condition such that the fact it’s a mailing list mirror isn’t detected? Note that to bypass these checks, the mail has to be sent to the category email address and not the site’s reply_by_email_address.

1 Like

Oh that’s interesting, and seems to be contrary to the guidance posted here to setup a mailing list mirror:

Subscribe to the mailing list using your Discourse email address (e.g., discourse@example.com).

I checked the email address subscribed to our mailing lists on behalf of Discourse and it’s indeed discourse@forum.torproject.org.

Should I be using a different email address here? If so, which one?

No, this is all fine.

The piece that you might be missing is this one:

(remember that Discourse only uses the message headers (To/CC) and does not know the envelope-to address)

For the tor-relays category, I have Custom incoming email address set to tor-relays@lists.torproject.org which I believe matches the To: header of the mails sent out by Mailman.

1 Like