dovecot-2.0: Added lda_original_recipient_header setting. Remove...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 14 16:45:07 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/8bd2bd410c73
changeset: 12111:8bd2bd410c73
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 14 13:45:57 2010 +0100
description:
Added lda_original_recipient_header setting. Removed non-standard use of Envelope-To: header.
diffstat:
doc/example-config/conf.d/15-lda.conf | 7 ++++++-
src/lda/main.c | 13 +++++++------
src/lib-lda/lda-settings.c | 2 ++
src/lib-lda/lda-settings.h | 1 +
src/lmtp/commands.c | 7 ++++++-
5 files changed, 22 insertions(+), 8 deletions(-)
diffs (93 lines):
diff -r d56a28e83f32 -r 8bd2bd410c73 doc/example-config/conf.d/15-lda.conf
--- a/doc/example-config/conf.d/15-lda.conf Tue Sep 14 13:17:18 2010 +0100
+++ b/doc/example-config/conf.d/15-lda.conf Tue Sep 14 13:45:57 2010 +0100
@@ -1,5 +1,5 @@
##
-## LDA specific settings
+## LDA specific settings (also used by LMTP)
##
# Address to use when sending rejection mails.
@@ -28,6 +28,11 @@
# Delimiter character between local-part and detail in email address.
#recipient_delimiter = +
+# Header where the original recipient address (SMTP's RCPT TO: address) is taken
+# from if not available elsewhere. With dovecot-lda -a parameter overrides this.
+# A commonly used header for this is X-Original-To.
+#lda_original_recipient_header =
+
# Should saving a mail to a nonexistent mailbox automatically create it?
#lda_mailbox_autocreate = no
diff -r d56a28e83f32 -r 8bd2bd410c73 src/lda/main.c
--- a/src/lda/main.c Tue Sep 14 13:17:18 2010 +0100
+++ b/src/lda/main.c Tue Sep 14 13:45:57 2010 +0100
@@ -405,13 +405,14 @@
mailbox_header_lookup_unref(&headers_ctx);
mail_set_seq(ctx.src_mail, 1);
+ if (ctx.dest_addr == NULL &&
+ *ctx.set->lda_original_recipient_header != '\0') {
+ ctx.dest_addr = mail_deliver_get_address(ctx.src_mail,
+ ctx.set->lda_original_recipient_header);
+ }
if (ctx.dest_addr == NULL) {
- ctx.dest_addr = mail_deliver_get_address(ctx.src_mail,
- "Envelope-To");
- if (ctx.dest_addr == NULL) {
- ctx.dest_addr = strchr(user, '@') != NULL ? user :
- t_strconcat(user, "@", ctx.set->hostname, NULL);
- }
+ ctx.dest_addr = strchr(user, '@') != NULL ? user :
+ t_strconcat(user, "@", ctx.set->hostname, NULL);
}
if (ctx.final_dest_addr == NULL)
ctx.final_dest_addr = ctx.dest_addr;
diff -r d56a28e83f32 -r 8bd2bd410c73 src/lib-lda/lda-settings.c
--- a/src/lib-lda/lda-settings.c Tue Sep 14 13:17:18 2010 +0100
+++ b/src/lib-lda/lda-settings.c Tue Sep 14 13:45:57 2010 +0100
@@ -25,6 +25,7 @@
DEF(SET_STR, rejection_reason),
DEF(SET_STR, deliver_log_format),
DEF(SET_STR, recipient_delimiter),
+ DEF(SET_STR, lda_original_recipient_header),
DEF(SET_BOOL, quota_full_tempfail),
DEF(SET_BOOL, lda_mailbox_autocreate),
DEF(SET_BOOL, lda_mailbox_autosubscribe),
@@ -41,6 +42,7 @@
"Your message to <%t> was automatically rejected:%n%r",
.deliver_log_format = "msgid=%m: %$",
.recipient_delimiter = "+",
+ .lda_original_recipient_header = "",
.quota_full_tempfail = FALSE,
.lda_mailbox_autocreate = FALSE,
.lda_mailbox_autosubscribe = FALSE
diff -r d56a28e83f32 -r 8bd2bd410c73 src/lib-lda/lda-settings.h
--- a/src/lib-lda/lda-settings.h Tue Sep 14 13:17:18 2010 +0100
+++ b/src/lib-lda/lda-settings.h Tue Sep 14 13:45:57 2010 +0100
@@ -11,6 +11,7 @@
const char *rejection_reason;
const char *deliver_log_format;
const char *recipient_delimiter;
+ const char *lda_original_recipient_header;
bool quota_full_tempfail;
bool lda_mailbox_autocreate;
bool lda_mailbox_autosubscribe;
diff -r d56a28e83f32 -r 8bd2bd410c73 src/lmtp/commands.c
--- a/src/lmtp/commands.c Tue Sep 14 13:17:18 2010 +0100
+++ b/src/lmtp/commands.c Tue Sep 14 13:45:57 2010 +0100
@@ -462,7 +462,12 @@
dctx.src_mail = src_mail;
dctx.src_envelope_sender = client->state.mail_from;
dctx.dest_user = client->state.dest_user;
- dctx.dest_addr = rcpt->address;
+ if (*dctx.set->lda_original_recipient_header != '\0') {
+ dctx.dest_addr = mail_deliver_get_address(src_mail,
+ dctx.set->lda_original_recipient_header);
+ }
+ if (dctx.dest_addr == NULL)
+ dctx.dest_addr = rcpt->address;
dctx.final_dest_addr = rcpt->address;
dctx.dest_mailbox_name = *rcpt->detail == '\0' ? "INBOX" : rcpt->detail;
dctx.save_dest_mail = array_count(&client->state.rcpt_to) > 1 &&
More information about the dovecot-cvs
mailing list