Emails forwarded to Service Desk email don't come in (when key in envelope-to header)
This is more or less an enhancement of #2247 (closed).
Additional to the already checked headers there is envelope-to
which, as my googling skills lead me to, seems used for multiple german providers. See https://www.verbraucherzentrale.de/wissen/digitale-welt/phishingradar/so-lesen-sie-den-mailheader-6077 (German text).
Use case
I setup up support@foo.bar
to forward mails to gitlab+myproject-@incoming.foo.bar
to set up a small service desk.
My mail provider 1&1 IONOS (https://www.ionos.de/) adds the service desk mail to an envelope-to
header.
Mail example:
Return-Path: <max@winterstein.mx>
Received: from [217.72.192.67] ([217.72.192.67]) by mx.kundenserver.de
(mxeue110 [217.72.192.67]) with ESMTPS (Nemesis) id 1MdMU2-1i0Y2E3ta4-00ZDyu
for <gitlab+myproject-@incoming.foo.bar>; Tue, 26 Nov 2019 15:22:42
+0100
Received: from smtprelay03.ispgateway.de ([80.67.29.28]) by mx.kundenserver.de
(mxeue110 [217.72.192.67]) with ESMTPS (Nemesis) id 1MnIdG-1i8D023ejs-00jA9A
for <support@foo.bar>; Tue, 26 Nov 2019 15:22:42 +0100
Received: from [10.240.177.4] (helo=EXFE04.EXCHANGE.INT)
by smtprelay03.ispgateway.de with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256)
(Exim 4.92.3)
(envelope-from <max@winterstein.mx>)
id 1iZbjm-000441-5H
for support@foo.bar; Tue, 26 Nov 2019 15:22:42 +0100
Received: from EXDAG29-1.EXCHANGE.INT (10.240.178.184) by
EXDAG29-2.EXCHANGE.INT (10.240.178.185) with Microsoft SMTP Server (TLS) id
15.0.1395.4; Tue, 26 Nov 2019 15:22:41 +0100
Received: from EXDAG29-1.EXCHANGE.INT ([10.240.179.57]) by
EXDAG29-1.EXCHANGE.INT ([10.240.179.57]) with mapi id 15.00.1395.000; Tue, 26
Nov 2019 15:22:41 +0100
From: "max@winterstein.mx" <max@winterstein.mx>
To: "support@foo.bar" <support@foo.bar>
Subject: test373
Thread-Topic: test373
Thread-Index: AQHVpGT2uiHl62aIf0OT/+w1gFu7uw==
Date: Tue, 26 Nov 2019 14:22:41 +0000
Message-ID: <7e2296f83dbf4de388cbf5f56f52c11f@EXDAG29-1.EXCHANGE.INT>
Accept-Language: de-DE, en-US
Content-Language: de-DE
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [10.10.10.10]
Content-Type: multipart/alternative;
boundary="_000_7e2296f83dbf4de388cbf5f56f52c11fEXDAG291EXCHANGEINT_"
MIME-Version: 1.0
Envelope-To: <gitlab+myproject-@incoming.foo.bar>
X-Spam-Flag: NO
X-UI-Filterresults: notjunk:1;V03:K0:rT/ntJHc7bk=:uI/HpEDkpjAJhvDklp81PXL+WS
TuAPOocZl2+lctDH05RHD/JdrwWLOdDWBIoKUjy7oweTrclrOkjV6mF6UbcB+uijFPWJc0QoP
nbZaKE5DFYhZiIWLtftfE74w3Inpa1myNtqrRnHWYNfodkfdWQsIg6C21VZezvBzGi1L5s6Ef
hK5R3JwEOLoORzT6qgYRFnvqbRSku7O96dxN/Ea9GqgGbqxTZ73BlL8hKsmJJ4ExRrL05854A
x1aearOcxlK1NUNKlTIgkiv+jYA+FWPWsAnmyIX1MtCYCeBvLVF/fXDvU6vKZ2+lrvT+XQZz+
c4uvnMqXbu0R03s9ffzEJta5NRzt2NW6SjB9xYQ4BOOHAIptJlsM0lsfKWKSKjj2QmtFzgABa
KFSlIgIWRzW6Q7qGKFxePqNYtHWHIBoCnMCu6WHUjVlKlA6d613UVXOj7o4bOR6totmD0Qswn
tomAAoYr27bh34Xrl4EJAH4P3zqy6JrkH12/iLPJjBm2IUmzpLp2N5UtqAnH2QqCHtzkpsrip
vbEvKApSR6SbBYKkb28/c5yhAPp57PMw3tGerPzXdMgMid14KgM5iwgDQGnkR9CFV6KtB53Fx
e5BNf2DPeMZU1TlR8EJK3zQ7Ze9fFdvDX8EX/Y4quhmUY7T4TgzDidJSUGLntQOO49cxhC0y4
tH52KRLOxA+qc3D36svvPdURLb9yBm4DJY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11fEXDAG291EXCHANGEINT_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
--_000_7e2296f83dbf4de388cbf5f56f52c11fEXDAG291EXCHANGEINT_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none"><!--P{margin-top:0;margin-b=
ottom:0;} --></style>
</head>
<body dir=3D"ltr" style=3D"font-size:12pt;color:#000000;background-color:#F=
FFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><br>
</p>
</body>
</html>
--_000_7e2296f83dbf4de388cbf5f56f52c11fEXDAG291EXCHANGEINT_--
Problem:
Currently gitlab supports only
to
referece
delivered_to
as fields to find the service desk key. This can be easily read from https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/email/receiver.rb .
Solution proposal
I think this could be handled quite easy. Inspired by !1810 (merged) i think a simple solution could be provided by adding a additional function
def find_key_from_envelope_to_header(mail)
Array(mail[:envelope-to]).find do |header|
key = Gitlab::IncomingEmail.key_from_address(header.value)
break key if key
end
end
and enhancing key_from_additional_headers
def key_from_additional_headers(mail)
find_key_from_references(mail) ||
find_key_from_delivered_to_header(mail) ||
find_key_from_envelope_to_header(mail)
end