1

I noticed that sometimes when I send a mail to a Gmail account. Gmail reject the message-id and regenerate the id.

You can identify this be by looking at the original message and seeing "SMTPIN_ADDED_BROKEN" string with in it.

For example:

<60f17262.1c69fb81.3e091.249dSMTPIN_ADDED_BROKEN@mx.google.com>

Then my original message-id added in the header "X-Google-Original-Message-ID"

As it makes it harder for me to track those messages at a later stage. I want to make sure in advance that all my message-id are valid. I guess that Google is validating the message-id against one of the RFC standards (probably https://datatracker.ietf.org/doc/html/rfc5322#section-3.6.4). Standards tend to be very wide and sometimes vague. Can someone provide more specific rules on how Google workspace validate message-ids.

Here is am example for message id that will be considered valid by the standard but rejected by Gmail

  <CAFDdQNjt907n4M"kpM2zaXHA82ZCSppZOc+bYoeKuWkatrSbmw@mail.gmail.com>

  =?UTF-8?Q?<762"51b6a8a859d4c2bd7ecd70a3aff811991d6b7@localhost.eu>?=

I guess gmail don't like the "

See also:
regex to validate a message-ID as per RFC2822

gmail is modifying header(Message-ID) of incoming mails

Update Following the answer from Rafa below. In rfc2822 you can find the following definition.

msg-id          =       [CFWS] "<" id-left "@" id-right ">" [CFWS]
id-left         =       dot-atom-text / no-fold-quote / obs-id-left
id-right        =       dot-atom-text / no-fold-literal / obs-id-right
no-fold-quote   =       DQUOTE *(qtext / quoted-pair) DQUOTE

Looking at DQUOTE for example if I follow the syntax correctly

DQUOTE - DQUOTE( ) finds the first double quote mark in the string and returns all characters from that point, until a second double quote mark is found. If the string does not contain at least two double quote marks, a null string is returned.

So the following should be a valid message id in RFC-2822 <test.a"rfc2822"c.123@message.com> But it's rejected

Haim Raman
  • 11,508
  • 6
  • 44
  • 70
  • Maybe it would be easier if you posted a sample message-id that Google didn't like? There's a low chance of anyone being able to answer this question unless they work at Google and are on the team that implemented this the way it stands right now. – jstedfast Jul 20 '21 at 02:13
  • I was actually hoping to get some official answer hopefully from someone at google and not something specific for few examples – Haim Raman Jul 20 '21 at 05:18
  • Can you provide your code which creates the message and sends it? – Rafa Guillermo Jul 20 '21 at 06:54
  • It basically creates a random 20 char left part of ascii chars then @ and then right part of ascii 16 chars looking at specific examples its easy to figure out the reason e.g. @@ .. etc. but I am looking for something more generic – Haim Raman Jul 20 '21 at 07:56
  • Why do you need an answer specifically from Google if you can look and see obvious flaws in the message-ids that your code is generating (like @@ as you mentioned?) – jstedfast Jul 20 '21 at 12:11
  • The same tool is running against o365 and it looks like o365 is less strict. I guess diffrent system has diffrent interoperation and I need to understand gmail in this case. – Haim Raman Jul 20 '21 at 12:36
  • Added an example that is valid by the standard and invalid in gmail – Haim Raman Jul 22 '21 at 05:30
  • Can you provide a bit of code that replicates this? – Rafa Guillermo Jul 22 '21 at 13:46
  • I can't share the code due to company regulation but I added one more example. – Haim Raman Jul 22 '21 at 15:49

1 Answers1

0

Answer:

Gmail uses RFC 2822 rather than RFC 5322 for the message-id in a message header. Make sure to use this specification when generating message-ids.

More Information:

From the documentation on creating messages:

The Gmail API requires MIME email messages compliant with RFC 2822 and encoded as base64url strings.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Rafa Guillermo
  • 14,474
  • 3
  • 18
  • 54
  • Thank you for. your answer although I don't think it answer my question. This is a more general comment on the message format not message-id. RFC-2822 includes message id section but again this may have some diffrent interpretation by diffrent MTA vendors – Haim Raman Jul 27 '21 at 11:02
  • Can you please explain what more you are looking for? Your question says `Can someone provide more specific rules on how Google workspace validate message-ids.` - to which I would say the specific rules are "Follow RFC 2822 and not RFC 5322". – Rafa Guillermo Jul 27 '21 at 11:04
  • I updated the question I hope this will help – Haim Raman Jul 27 '21 at 11:43