dovecot-2.0-pigeonhole: Vacation extension: from address of repl...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Tue Apr 20 00:39:01 EEST 2010
details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/cb4c3ce31192
changeset: 1258:cb4c3ce31192
user: Stephan Bosch <stephan at rename-it.nl>
date: Mon Apr 19 23:38:54 2010 +0200
description:
Vacation extension: from address of reply is now by default equal to whatever known recipient alias matched the headers of the message.
diffstat:
src/lib-sieve/plugins/vacation/cmd-vacation.c | 20 ++++--
tests/extensions/vacation/smtp.svtest | 86 +++++++++++++++++++++++++---
2 files changed, 88 insertions(+), 18 deletions(-)
diffs (191 lines):
diff -r d41e45e86988 -r cb4c3ce31192 src/lib-sieve/plugins/vacation/cmd-vacation.c
--- a/src/lib-sieve/plugins/vacation/cmd-vacation.c Mon Apr 19 14:18:17 2010 +0200
+++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c Mon Apr 19 23:38:54 2010 +0200
@@ -868,7 +868,7 @@
static bool act_vacation_send
(const struct sieve_action_exec_env *aenv, struct act_vacation_context *ctx,
- const char *sender, const char *recipient)
+ const char *reply_to, const char *reply_from)
{
const struct sieve_message_data *msgdata = aenv->msgdata;
const struct sieve_script_env *senv = aenv->scriptenv;
@@ -903,7 +903,7 @@
/* Open smtp session */
- smtp_handle = sieve_smtp_open(senv, sender, NULL, &f);
+ smtp_handle = sieve_smtp_open(senv, reply_to, NULL, &f);
outmsgid = sieve_message_get_new_id(senv);
/* Produce a proper reply */
@@ -914,15 +914,15 @@
if ( ctx->from != NULL && *(ctx->from) != '\0' )
rfc2822_header_field_utf8_printf(f, "From", "%s", ctx->from);
- else if ( recipient != NULL )
- rfc2822_header_field_printf(f, "From", "<%s>", recipient);
+ else if ( reply_from != NULL )
+ rfc2822_header_field_printf(f, "From", "<%s>", reply_from);
else
rfc2822_header_field_printf(f, "From", "Postmaster <%s>", senv->postmaster_address);
/* FIXME: If From header of message has same address, we should use that in
* stead properly include the phrase part.
*/
- rfc2822_header_field_printf(f, "To", "<%s>", sender);
+ rfc2822_header_field_printf(f, "To", "<%s>", reply_to);
if ( _contains_8bit(subject) )
rfc2822_header_field_utf8_printf(f, "Subject", "%s", subject);
@@ -964,7 +964,7 @@
sieve_result_error(aenv,
"failed to send vacation response to <%s> "
"(refer to server log for more information)",
- str_sanitize(sender, 128));
+ str_sanitize(reply_to, 128));
return TRUE;
}
@@ -998,6 +998,7 @@
const char *const *headers;
const char *sender = sieve_message_get_sender(aenv->msgctx);
const char *recipient = sieve_message_get_recipient(aenv->msgctx);
+ const char *reply_from = NULL;
/* Is the recipient unset?
*/
@@ -1097,8 +1098,10 @@
if ( mail_get_headers_utf8
(msgdata->mail, *hdsp, &headers) >= 0 && headers[0] != NULL ) {
- if ( _contains_my_address(headers, recipient) )
+ if ( _contains_my_address(headers, recipient) ) {
+ reply_from = recipient;
break;
+ }
if ( ctx->addresses != NULL ) {
bool found = FALSE;
@@ -1106,6 +1109,7 @@
while ( !found && *my_address != NULL ) {
found = _contains_my_address(headers, *my_address);
+ reply_from = *my_address;
my_address++;
}
@@ -1125,7 +1129,7 @@
/* Send the message */
- if ( act_vacation_send(aenv, ctx, sender, recipient) ) {
+ if ( act_vacation_send(aenv, ctx, sender, reply_from) ) {
sieve_result_log(aenv, "sent vacation response to <%s>",
str_sanitize(sender, 128));
diff -r d41e45e86988 -r cb4c3ce31192 tests/extensions/vacation/smtp.svtest
--- a/tests/extensions/vacation/smtp.svtest Mon Apr 19 14:18:17 2010 +0200
+++ b/tests/extensions/vacation/smtp.svtest Mon Apr 19 23:38:54 2010 +0200
@@ -15,21 +15,21 @@
test_set "envelope.to" "timo at iki.fi";
test "Basic" {
- vacation :addresses "tss at iki.fi" :from "Timo Sirainen <tss at iki.fi>" "I am gone";
+ vacation :addresses "tss at iki.fi" :from "Timo Sirainen <sirainen at iki.fi>" "I am gone";
if not test_result_execute {
- test_fail "failed to execute vacation";
- }
+ test_fail "failed to execute vacation";
+ }
- test_message :smtp 0;
+ test_message :smtp 0;
- if not address :is "to" "sirius at rename-it.nl" {
- test_fail "to address incorrect";
- }
+ if not address :is "to" "sirius at rename-it.nl" {
+ test_fail "to address incorrect";
+ }
- if not address :is "from" "tss at iki.fi" {
- test_fail "from address incorrect";
- }
+ if not address :is "from" "sirainen at iki.fi" {
+ test_fail "from address incorrect";
+ }
if not envelope :is "to" "sirius at rename-it.nl" {
test_fail "envelope recipient incorrect";
@@ -54,3 +54,69 @@
test_fail "reject sent message to NULL sender";
}
}
+
+test_result_reset;
+
+test_set "message" text:
+From: stephan at rename-it.nl
+To: timo at iki.fi
+Cc: stephan at drunksnipers.com
+Subject: Frop!
+
+Frop!
+.
+;
+
+test_set "envelope.from" "sirius at rename-it.nl";
+test_set "envelope.to" "timo at iki.fi";
+
+test "Envelope.to == To" {
+ vacation "I am gone";
+
+ if not test_result_execute {
+ test_fail "failed to execute vacation";
+ }
+
+ test_message :smtp 0;
+
+ if not address :is "from" "timo at iki.fi" {
+ test_fail "from address incorrect";
+ }
+
+ if not envelope :is "from" "" {
+ test_fail "envelope sender not null";
+ }
+}
+
+test_result_reset;
+
+test_set "message" text:
+From: stephan at rename-it.nl
+To: tss at iki.fi
+Cc: stephan at drunksnipers.com
+Subject: Frop!
+
+Frop!
+.
+;
+
+test_set "envelope.from" "sirius at rename-it.nl";
+test_set "envelope.to" "timo at iki.fi";
+
+test "Envelope.to != To" {
+ vacation :addresses "tss at iki.fi" "I am gone";
+
+ if not test_result_execute {
+ test_fail "failed to execute vacation";
+ }
+
+ test_message :smtp 0;
+
+ if not address :is "from" "tss at iki.fi" {
+ test_fail "from address incorrect";
+ }
+
+ if not envelope :is "from" "" {
+ test_fail "envelope sender not null";
+ }
+}
More information about the dovecot-cvs
mailing list