1

I need to retrieve some parts of a message which looks like

Subject: Test message
Message-Id: <2788db2f-b5c3-4b8c-881e-362c3df4f915@server.local>
Mime-Version: 1.0
Content-Type: multipart/report; boundary="----=_Part_fba0c199dfcd4d60ae506b37a6320a84"; report-type=notification
To: adam@test.local
Date: Mon, 17 Sep 2018 16:21:45 -0400 (EDT)
From: postmaster@server.local


------=_Part_fba0c199dfcd4d60ae506b37a6320a84
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

BTW, this is the correct notification ... it should be "failed" not "failure".
------=_Part_fba0c199dfcd4d60ae506b37a6320a84
Content-Type: message/notification
Content-Transfer-Encoding: 7bit

Final-Recipient: rfc822; eve@test.local
Original-Message-ID: <06dbfc12-57a5-49bd-84bd-a24bc3ba1e42@fake.cernerasp>

------=_Part_fba0c199dfcd4d60ae506b37a6320a84—

for an example I need to grab what is after Final-Recipient: rfc822; and Original-Message-ID: and store them as variables

I have tried to do something like

if body :raw :contains ["Original-Message-ID:"] {
  set "Original-Message-ID" "${0}";
}

but variable set as Original-Message-ID doesn't contain what is after it in the message.

JackTheKnife
  • 371
  • 1
  • 6
  • 24

1 Answers1

1

It came up that the body test will definitely not work with match variables:

https://www.rfc-editor.org/rfc/rfc5173#section-6

Wildcard expressions used with "body" are exempt from the side effects described in [VARIABLES]. That is, they MUST NOT set match variables (${1}, ${2}...) to the input values corresponding to wildcard sequences in the matched pattern.

The MIME Sieve extensions will likely provide what is needed https://www.rfc-editor.org/rfc/rfc5703 or pipe message to a script and process it there, what I have done in my case.

JackTheKnife
  • 371
  • 1
  • 6
  • 24
  • Looks like the maintainer intended to add support for this 8 years ago but never got around to it: https://dovecot.dovecot.narkive.com/gfZuhK9g/sieve-vacation-attach-original-message https://dovecot.org/pipermail/dovecot/2014-March/095346.html – Nick Sweeting Jul 15 '22 at 02:10