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
- If you haven't set up
incoming_email
orservice_desk_email
for email ingestion, please add this to yourgitlab.yml
file in thedevelopment:
section. Please restart GDK withgdk restart
:incoming_email: enabled: true address: "incoming+%{key}@example.com"
mail_room
, but we don't need that here. - 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 To: to@example.com From: user@example.com X-Original-To: #{service_desk_address} Subject: From X-Original-To Issue email ingested via X-Original-To header. EMAIL EmailReceiverWorker.new.perform(email_raw)
- Check whether the issue has been created successfully
i = Issue.last i.title # should be "From X-Original-To"
Edited by Marc Saleiko