diff --git a/src/lib-sieve/cmd-redirect.c b/src/lib-sieve/cmd-redirect.c index 322ea15843ef05bc67af73653813bae06c9a2afc..32e01b7ae3d824aacb826b8280b3e932f1a75b16 100644 --- a/src/lib-sieve/cmd-redirect.c +++ b/src/lib-sieve/cmd-redirect.c @@ -362,7 +362,8 @@ static int act_redirect_send /* Prepend sieve headers (should not affect signatures) */ rfc2822_header_append(hdr, "X-Sieve", SIEVE_IMPLEMENTATION, FALSE, NULL); - if ( (aenv->flags & SIEVE_EXECUTE_FLAG_NO_ENVELOPE) == 0 ) + if ( svinst->user_email == NULL && + (aenv->flags & SIEVE_EXECUTE_FLAG_NO_ENVELOPE) == 0 ) user_email = sieve_message_get_final_recipient(msgctx); else user_email = sieve_get_user_email(aenv->svinst); diff --git a/tests/execute/smtp.svtest b/tests/execute/smtp.svtest index 83098cf596101103a0398f26671377bac2d75765..e19540905470684d738271702725fdddbb6ab55f 100644 --- a/tests/execute/smtp.svtest +++ b/tests/execute/smtp.svtest @@ -36,6 +36,11 @@ test "Redirect" { if not envelope :is "from" "sirius@example.org" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } } test_result_reset; @@ -66,6 +71,11 @@ test "Redirect from <>" { if not envelope :is "from" "" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } } test_result_reset; @@ -99,6 +109,11 @@ test "Redirect from [recipient]" { if not envelope :is "from" "timo@example.net" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } } test_result_reset; @@ -133,8 +148,12 @@ test "Redirect from [original recipient]" { if not envelope :is "from" "tss@example.net" { test_fail "envelope sender incorrect"; } -} + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } +} test_result_reset; test_set "message" text: @@ -168,6 +187,11 @@ test "Redirect from [<explicit>]" { if not envelope :is "from" "backscatter@example.net" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } } test_result_reset; @@ -201,6 +225,11 @@ test "Redirect from [<>]" { if not envelope :is "from" "" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } } test_result_reset; @@ -235,6 +264,11 @@ test "Redirect from <> with [<explicit>]" { if not envelope :is "from" "" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } } test_result_reset; @@ -265,6 +299,11 @@ test "Redirect from [user email - fallback default]" { if not envelope :is "from" "timo@example.net" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "timo@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } } test_result_reset; @@ -300,5 +339,10 @@ test "Redirect from [user email]" { if not envelope :is "from" "t.sirainen@example.net" { test_fail "envelope sender incorrect"; } + + if not header :contains "x-sieve-redirected-from" + "t.sirainen@example.net" { + test_fail "x-sieve-redirected-from header is incorrect"; + } }