Is the order of e-mail recipients guaranteed to be constant?
Solution 1:
Yes, unless some party involved in the delivery is doing fishy things.
The original content of the header fields in an email message comes from the sender's MUA (mail user agent, i.e. mail software). It's technically possible for an intermediary system handling the mail to modify them, but that's against expectations if not against formal protocol standards, and further, if DKIM is involved, doing it at any stage after the outgoing site's mail system has signed the headers with the DKIM keys would make the signature mismatch. Normally, intermediary systems handling forwarding of your message will prepend headers (Received:
, DKIM signatures, spam likelihood scores, etc.) to the message, not modify the existing ones.
Note that the To:
and Cc:
headers in an email message are purely informative; they are not part of the mechanism for how the mail gets delivered to the correct party. Rather, when your MUA submits the mail via SMTP to your mail provider's submission port, the RCPT TO
command(s) specify the addresses it should be delivered to. The MUA normally derives these from the headers, but doesn't have to (and in the case of Bcc:
, the header they're derived from was stripped before being sent).
To address the Update to the question: I'm not aware of any "laws" governing what MUAs must do, and even if there were, the extent to which many popular existing ones violate normal expectations/etiquette (for example, hiding email addresses and only showing unauthenticated names, badly reflowing text, etc.) leads me to say you couldn't trust them to follow such "laws" anyway. If you want to know if a particular sender's MUA may have ordered the recipients differently from how the sender wrote/selected them, or if a particular recipient's MUA may have presented them different from their order in the message, you really need to know what particular software they're using and examine that software's behavior.
For what it's worth, I don't recall ever having seen such reordering, but I've only used/observed a very small number of MUAs out of all the ones out there, so it's possible that some so reorder things.
Solution 2:
It has been a few years that I went through the SMTP protocol specification, but as far as I can remember there is NOTHING in there that prescribes maintaining that order.
To my knowledge the SMTP protocol ONLY prescribes the message format and mandatory and optional fields within that format. It does give some guidance on the order in which mandatory fields are to be send, but for fields with multiple values (like the recipients) it only says how those fields should be formatted. It doesn't say that the order of multiple values within that field is important or should be preserved.
And any mail-server/relay that receives and forwards an email is free to temporary store that email before sending it on in whatever format it pleases and reconstruct the SMTP message as needed when transmitting it further.
If it does any sort of sorting on the list of recipients that may change the order.
And the sending and receiving mail-clients may deal with this however tehy like as well.
The sending client can re-order what you typed before creating the SMTP message and the receiving mail-client can re-arrange on receival before showing it to you.
The send/receive protocol has nothing to do with all that.
It is just concerned with a properly formatted SMTP mesage.
It isn't the protocols job to care about what the application layer above it does with the message.