Sometimes email notifications are not received in DevSecOps (part2)
Most often, but not systematically, the DevSecOps transfer notification emails are not received.
Examples:
No email was received for uploads with logs:
"requestId": 11534,
"action": "Transfer",
"userEmail": "jensXXXXX",
"artefact": "ABS:WPI(1.0.0)",
"sourceDataspace": "qa:reset",
"destinationDataspace": "qa:stable",
"sourceData": "all (unfiltered) data",
"submissionTime": "2022-06-24T15:29:45.15",
"executionStart": "2022-06-24T15:29:45.563",
"executionEnd": "2022-06-24T15:29:52.837",
"executionStatus": "Completed",
"outcome": "Success",
Notes:
- The valid email has been replaced above with "jensXXXXX" for privacy reasons.
Technical notes
We do not receive DevSecOps transfer messages because of a "missing a valid messageId header" - gmail is refusing the reception of the message. In the EMAIL standard, the message id header is not required currently, but is used by several spam filters. And GMAIL is very demanding. When used it needs to be unique and respect the format defined in https://www.ietf.org/rfc/rfc2822.html#section-3.6.4:
Though optional, every message SHOULD have a "Message-ID:" field.
Furthermore, reply messages SHOULD have "In-Reply-To:" and
"References:" fields as appropriate, as described below.
The "Message-ID:" field contains a single unique message identifier.
The "References:" and "In-Reply-To:" field each contain one or more
unique message identifiers, optionally separated by CFWS.
The message identifier (msg-id) is similar in syntax to an angle-addr
construct without the internal CFWS.
message-id = "Message-ID:" msg-id CRLF
in-reply-to = "In-Reply-To:" 1*msg-id CRLF
references = "References:" 1*msg-id CRLF
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
To solve this issue, the transfer SMTP request could add the message-id header as follow:
mailMessage.Headers.Add("Message-Id",
String.Format("<{0}@{1}>",
Guid.NewGuid().ToString(),
"mail.example.com"));