diff --git a/src/lib-sieve/plugins/vacation/cmd-vacation.c b/src/lib-sieve/plugins/vacation/cmd-vacation.c index de31cff882c5b5a22debd45be4a271e1fb904c7d..e6731271180e936af8b98c93f170f8c968699d80 100644 --- a/src/lib-sieve/plugins/vacation/cmd-vacation.c +++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c @@ -982,6 +982,9 @@ static int act_vacation_send rfc2822_header_write(msg, "Auto-Submitted", "auto-replied (vacation)"); rfc2822_header_write(msg, "Precedence", "bulk"); + /* Prevent older Microsoft products from replying to this message */ + rfc2822_header_write(msg, "X-Auto-Response-Suppress", "All"); + rfc2822_header_write(msg, "MIME-Version", "1.0"); if ( !ctx->mime ) { @@ -1158,6 +1161,32 @@ static int act_vacation_commit hdsp++; } + /* Check for the (non-standard) Microsoft X-Auto-Response-Suppress header */ + if ( mail_get_headers + (mail, "x-auto-response-suppress", &headers) < 0 ) { + return sieve_result_mail_error(aenv, mail, + "vacation action: " + "failed to read header field `x-auto-response-suppress'"); + } + /* Theoretically multiple headers could exist, so lets make sure */ + hdsp = headers; + while ( *hdsp != NULL ) { + const char *const *flags = t_strsplit(*hdsp, ","); + while ( *flags != NULL ) { + const char *flag = t_str_trim(*flags, " \t"); + if ( strcasecmp(flag, "All") == 0 || + strcasecmp(flag, "OOF") == 0 ) { + sieve_result_global_log(aenv, + "discarding vacation response to message from <%s> " + "(`%s' flag found in x-auto-response-suppress header)", + str_sanitize(sender, 128), flag); + return SIEVE_EXEC_OK; + } + flags++; + } + hdsp++; + } + /* Do not reply to system addresses */ if ( _is_system_address(sender) ) { sieve_result_global_log(aenv, diff --git a/tests/extensions/vacation/reply.svtest b/tests/extensions/vacation/reply.svtest index 0e84af9f4ad7783424238c67ec6a4a590029c481..49061beb78590ef78121a781ff4a531f1fe5cf43 100644 --- a/tests/extensions/vacation/reply.svtest +++ b/tests/extensions/vacation/reply.svtest @@ -146,6 +146,99 @@ test "No reply to auto-submitted mail" { } } +/* + * No reply to Microsoft X-Auto-Response-Suppress - All + */ + +test_result_reset; + +test_set "message" text: +From: spam@example.com +To: stephan@example.com +X-Auto-Response-Suppress: All +Subject: Frop! + +Frop! +. +; + +test_set "envelope.from" "spam@example.com"; +test_set "envelope.to" "stephan@example.com"; + +test "No reply to Microsoft X-Auto-Response-Suppress - All" { + vacation "I am gone"; + + if not test_result_execute { + test_fail "failed to execute vacation"; + } + + if test_message :smtp 0 { + test_fail "vacation not supposed to send message"; + } +} + +/* + * No reply to Microsoft X-Auto-Response-Suppress - OOF + */ + +test_result_reset; + +test_set "message" text: +From: spam@example.com +To: stephan@example.com +X-Auto-Response-Suppress: OOF +Subject: Frop! + +Frop! +. +; + +test_set "envelope.from" "spam@example.com"; +test_set "envelope.to" "stephan@example.com"; + +test "No reply to Microsoft X-Auto-Response-Suppress - OOF" { + vacation "I am gone"; + + if not test_result_execute { + test_fail "failed to execute vacation"; + } + + if test_message :smtp 0 { + test_fail "vacation not supposed to send message"; + } +} + +/* + * No reply to Microsoft X-Auto-Response-Suppress - DR,OOF,RN + */ + +test_result_reset; + +test_set "message" text: +From: spam@example.com +To: stephan@example.com +X-Auto-Response-Suppress: DR, OOF, RN +Subject: Frop! + +Frop! +. +; + +test_set "envelope.from" "spam@example.com"; +test_set "envelope.to" "stephan@example.com"; + +test "No reply to Microsoft X-Auto-Response-Suppress - DR,OOF,RN" { + vacation "I am gone"; + + if not test_result_execute { + test_fail "failed to execute vacation"; + } + + if test_message :smtp 0 { + test_fail "vacation not supposed to send message"; + } +} + /* * No reply to system address */ @@ -252,6 +345,7 @@ To: stephan@example.com Subject: Frop! Auto-submitted: no Precedence: normal +X-Auto-Response-Suppress: None Frop! .