Emulating behavior of git-send-email

Hey all-
I’m trying to use gitlab to operate as the backend for a more traditional email based development model. Currently I have the following setup:

  1. A master development tree Tree(M)

  2. A set of forked development trees (1 per user) Tree(C1), Tree(C2)…Tree(Cn)

Developers will develop features/fixes and push to Tree(Cn), then open merge requests from Tree(Cn)Branch(x) to Tree(M)Branch(y)

Nominally, the traditional workflow would be for developers to write patches in a local tree, then send patch series to a mailing list via git-send-email, where others would review, and comment.

In an effort to modernize this flow, I’d like to be able to have gitlab emulate the functionality of git-send-email. That is to say, when a user opens a merge request from Tree(Cn)Branch(x) toTree§Branch(y), I would like gitlab to:

  1. Send a notification email to the mailing list announcing the new merge request
  2. Send X replies to (1) (1 email for each patch in the series), with the Gitlab email headers set such that replying to any of the patches would be translated to a discussion in the merge request.

Item (1) is of course easy, as that notification option already exists. But (2) seems much more difficult. Theres a send email on push integration that sounds promising, but it only triggers on push to Tree(Cn), not Tree(M), which means the patch emails would get sent prior to the new merge request notification (implying the in-reply-to headers wouldn’t be set properly)

I had thought about just using git-send-email directly and constructing the X-GitLab headers myself, and that seems feasible (most of the headers can be computed fairly easily), with the exception of the X-GitLab-reply-key, which seems needed to correlate responses to emails to the requisite discussions in the MR. And I can find no way to generate new reply keys, or fetch existing keys through the REST api.

So, has anyone encountered this use case before, and if so, does anyone have throughts as to how to implement it?