changeset 12110:d56a28e83f32

lda: Added -r parameter to specify final recipient address. (As opposed to -a which specifies original recipient address.) This is going to be used by Sieve checks.
author Timo Sirainen <tss@iki.fi>
date Tue, 14 Sep 2010 13:17:18 +0100
parents d6dc68825427
children 8bd2bd410c73
files src/lda/main.c src/lib-lda/mail-deliver.h src/lmtp/commands.c
diffstat 3 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lda/main.c	Tue Sep 14 11:06:44 2010 +0100
+++ b/src/lda/main.c	Tue Sep 14 13:17:18 2010 +0100
@@ -251,7 +251,7 @@
 	master_service = master_service_init("lda",
 		MASTER_SERVICE_FLAG_STANDALONE |
 		MASTER_SERVICE_FLAG_DONT_LOG_TO_STDERR,
-		&argc, &argv, "a:d:ef:km:p:");
+		&argc, &argv, "a:d:ef:km:p:r:");
 
 	memset(&ctx, 0, sizeof(ctx));
 	ctx.pool = pool_alloconly_create("mail deliver context", 256);
@@ -262,7 +262,7 @@
 	while ((c = master_getopt(master_service)) > 0) {
 		switch (c) {
 		case 'a':
-			/* destination address */
+			/* original recipient address */
 			ctx.dest_addr = optarg;
 			break;
 		case 'd':
@@ -294,6 +294,10 @@
 			/* input path */
 			path = t_abspath(optarg);
 			break;
+		case 'r':
+			/* final recipient address */
+			ctx.final_dest_addr = optarg;
+			break;
 		default:
 			print_help();
 			return EX_USAGE;
@@ -409,6 +413,8 @@
 				t_strconcat(user, "@", ctx.set->hostname, NULL);
 		}
 	}
+	if (ctx.final_dest_addr == NULL)
+		ctx.final_dest_addr = ctx.dest_addr;
 
 	if (mail_deliver(&ctx, &storage) < 0) {
 		if (storage == NULL) {
--- a/src/lib-lda/mail-deliver.h	Tue Sep 14 11:06:44 2010 +0100
+++ b/src/lib-lda/mail-deliver.h	Tue Sep 14 13:17:18 2010 +0100
@@ -21,8 +21,10 @@
 
 	/* Destination user */
 	struct mail_user *dest_user;
-	/* Destination email address */
+	/* Original recipient address */
 	const char *dest_addr;
+	/* Final recipient address (typically same as dest_addr) */
+	const char *final_dest_addr;
 	/* Mailbox where mail should be saved, unless e.g. Sieve does
 	   something to it. */
 	const char *dest_mailbox_name;
--- a/src/lmtp/commands.c	Tue Sep 14 11:06:44 2010 +0100
+++ b/src/lmtp/commands.c	Tue Sep 14 13:17:18 2010 +0100
@@ -463,6 +463,7 @@
 	dctx.src_envelope_sender = client->state.mail_from;
 	dctx.dest_user = client->state.dest_user;
 	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 &&
 		client->state.first_saved_mail == NULL;