]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added lda_original_recipient_header setting. Removed non-standard use of Envelope...
authorTimo Sirainen <tss@iki.fi>
Tue, 14 Sep 2010 12:45:57 +0000 (13:45 +0100)
committerTimo Sirainen <tss@iki.fi>
Tue, 14 Sep 2010 12:45:57 +0000 (13:45 +0100)
doc/example-config/conf.d/15-lda.conf
src/lda/main.c
src/lib-lda/lda-settings.c
src/lib-lda/lda-settings.h
src/lmtp/commands.c

index ad7db56b1ba174bc4cba46a970314b221cce0cba..c8dcd2e88915e8141d7708df3de03e931374b376 100644 (file)
@@ -1,5 +1,5 @@
 ##
-## LDA specific settings
+## LDA specific settings (also used by LMTP)
 ##
 
 # Address to use when sending rejection mails.
 # 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
 
index 9cacbde204ff8636bd50880c52674e6fa657f59c..865f767ff369a9324b784b6e29d83b90e29f169c 100644 (file)
@@ -405,13 +405,14 @@ int main(int argc, char *argv[])
        mailbox_header_lookup_unref(&headers_ctx);
        mail_set_seq(ctx.src_mail, 1);
 
-       if (ctx.dest_addr == NULL) {
+       if (ctx.dest_addr == NULL &&
+           *ctx.set->lda_original_recipient_header != '\0') {
                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.set->lda_original_recipient_header);
+       }
+       if (ctx.dest_addr == 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;
index 366560a905a5422ef8e87a15ee882c13a617275b..828c42d48c89497f3a61ba33e16c6f887b9b8d6b 100644 (file)
@@ -25,6 +25,7 @@ static const struct setting_define lda_setting_defines[] = {
        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 @@ static const struct lda_settings lda_default_settings = {
                "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
index d0f92b5af44e77bbc32d00758decc97cdb610010..60d23aba441c519d606be274f272b7cb26cfea55 100644 (file)
@@ -11,6 +11,7 @@ struct lda_settings {
        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;
index cf34a6b578698d9cab572d4e1fa5bc7d589f4b73..67bcfb5e2328df5fbc468c1f26b1dbeb1c62defd 100644 (file)
@@ -462,7 +462,12 @@ client_deliver(struct client *client, const struct mail_recipient *rcpt,
        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 &&