Skip to content

Support X-Original-To headers for email ingestion

What does this MR do and why?

This adds X-Original-To to the supported headers for email ingestion. That means you can send emails to one of the mailboxes GitLab ingests emails from and GitLab will also try to find a project or sent notification key in the X-Original-To headers.

Also refactors parts of spec/lib/gitlab/email/receiver_spec.rb a bit.

Solves use case in #435206 (comment 1791092532)

Contributes to discussion on #435206 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings


How to set up and validate locally

  1. If you haven't set up incoming_email or service_desk_email for email ingestion, please add this to your gitlab.yml file in the development: section. Please restart GDK with gdk restart:
      enabled: true
      address: "incoming+%{key}"
    This will allow you to see the Service Desk section in the settings and generate project-specific email addresses. You won't be able to ingest real emails using mail_room, but we don't need that here.
  2. Run this script to ingest an email via the receiver (that is usually called by the internal API endpoint that receives emails from mail_room.
    project = Project.find(7)
    service_desk_address = project.service_desk_incoming_address
    email_raw = <<~EMAIL
    X-Original-To: #{service_desk_address}
    Subject: From X-Original-To
    Issue email ingested via X-Original-To header.
  3. Check whether the issue has been created successfully
    i = Issue.last
    i.title # should be "From X-Original-To"
Edited by Marc Saleiko

Merge request reports