From 5ed91c57b586ec9f24fd90b168ce97e188741b25 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Tue, 2 Aug 2011 16:25:04 +0200
Subject: [PATCH] lib-sieve: added X-Sieve-Redirected-From header for people
 using SPF/SRS.

---
 src/lib-sieve/cmd-redirect.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lib-sieve/cmd-redirect.c b/src/lib-sieve/cmd-redirect.c
index 70b177c80..f9f524ea6 100644
--- a/src/lib-sieve/cmd-redirect.c
+++ b/src/lib-sieve/cmd-redirect.c
@@ -295,11 +295,13 @@ static void act_redirect_print
 static bool act_redirect_send	
 (const struct sieve_action_exec_env *aenv, struct act_redirect_context *ctx)
 {
-	static const char *hide_headers[] = { "Return-Path", "X-Sieve" };
+	static const char *hide_headers[] = 
+		{ "Return-Path", "X-Sieve", "X-Sieve-Redirected-From" };
 
 	const struct sieve_message_data *msgdata = aenv->msgdata;
 	const struct sieve_script_env *senv = aenv->scriptenv;
 	const char *sender = sieve_message_get_sender(aenv->msgctx);
+	const char *recipient = sieve_message_get_final_recipient(aenv->msgctx);
 	struct istream *input, *crlf_input;
 	void *smtp_handle;
 	FILE *f;
@@ -328,8 +330,9 @@ static bool act_redirect_send
 	/* Make sure the message contains CRLF consistently */
 	crlf_input = i_stream_create_crlf(input);
 
-	/* Prepend sieve version header (should not affect signatures) */
+	/* Prepend sieve headers (should not affect signatures) */
 	rfc2822_header_field_write(f, "X-Sieve", SIEVE_IMPLEMENTATION);
+	rfc2822_header_field_write(f, "X-Sieve-Redirected-From", recipient);
 
 	/* Pipe the message to the outgoing SMTP transport */
 	while ((ret = i_stream_read_data(crlf_input, &data, &size, 0)) > 0) {	
-- 
GitLab