##
-## 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
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;
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),
"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
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;
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 &&