Every email should have a unique Message-ID

email

(Michael Brown) #1

Every single email that Discourse generates must have a unique Message-ID.

The current IDs we generate are not unique - the same Message-ID will get used for every distinct email going out for a particular post (i.e. if it’s sent to 10 users, that Message-ID gets repeated 10 times):

            if post.post_number == 1
              "<topic/#{topic_id}@#{host}>"
            else
              "<topic/#{topic_id}/#{post.id}@#{host}>"
            end

:arrow_down:

Message-ID: <topic/3981/53574@meta.discourse.org>

We should append some randomness onto the Message ID (which we can obviously remove when parsing incoming email).


(Régis Hanol) #2

Does that cause any issues? I mean the message id is unique per “message”.


(Michael Brown) #3

I suspect it may be causing problems but am not entirely sure it is. 99.9% of the time things will be fine, but I know it would have caused problems at companies I’ve worked at previously (e.g. email scanning gateways may reject duplicate Message-IDs with different content).

Note the differing content comes from the post getting emailed to different people.


(Stephen) #4

This may explain an email issue I’ve been looking into.


(Matt Palmer) #5

No, it’s unique per Discourse post. The “message” in an e-mail message ID is the e-mail.


(Régis Hanol) #6

I know, I was half joking / half trolling :wink:

I didn’t know (think) about the email scanning gateway issue. I will get it fixed :ok_hand:


(Jeff Atwood) #8

I suggest appending the target user ID in the identifier, so the identifier actually makes sense versus “here’s a random string!”


(Michael Brown) #9

It really doesn’t need to make sense - “random string” is VERY typical.

If you want it to, I would do both - add the target user.id as well as random data (who knows - perhaps it’s possible now or in the future for the same user to be emailed about a post twice).


(Dan Ungureanu) #10

I am not exactly sure what’s up with the secondary emails feature, but if all of them are used to notify the user your approach may cause issues. If a user has multiple email addresses then it is going to receive multiple emails with the same Message-ID.


(Jeff Atwood) #11

I think they’re only used for login, not notifications.