From 94a3e2d78bfdd66875257fa3ad98938002a19383 Mon Sep 17 00:00:00 2001 From: SJ Date: Tue, 27 Nov 2012 13:16:30 +0100 Subject: [PATCH] added x-envelop-to: support to see the envelope recipient address --- etc/example.conf | 14 ++++++++++++++ src/cfg.c | 1 + src/cfg.h | 1 + src/config.h | 2 +- src/parser.c | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/etc/example.conf b/etc/example.conf index 461293df..fc24e48d 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -66,6 +66,20 @@ cipher_list=HIGH:MEDIUM ; piler's own header to indicate previously archived messages piler_header_field=X-piler: piler already archived this email +; extra header field to treat as To: +; +; to make postfix to insert the envelope recipient address to the email +; header, do the following: +; +; /etc/postfix/main.cf: +; +; smtpd_recipient_restrictions = reject_non_fqdn_recipient, ... check_recipient_access pcre:$config_directory/x-add-envelope-to, ... +; +; /etc/postfix/x-add-envelope-to: +; +; /(.*)/ prepend X-Envelope-To: $1 +; +extra_to_field=X-Envelope-To: ; whether to archive an email not having a Message-ID header line (1) ; or not (0). diff --git a/src/cfg.c b/src/cfg.c index 0497bd8a..d7d5f17c 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -67,6 +67,7 @@ struct _parse_rule config_parse_rules[] = { "clamd_socket", "string", (void*) string_parser, offsetof(struct __config, clamd_socket), CLAMD_SOCKET, MAXVAL-1}, { "debug", "integer", (void*) int_parser, offsetof(struct __config, debug), "0", sizeof(int)}, { "default_retention_days", "integer", (void*) int_parser, offsetof(struct __config, default_retention_days), "2557", sizeof(int)}, + { "extra_to_field", "string", (void*) string_parser, offsetof(struct __config, extra_to_field), "", MAXVAL-1}, { "hostid", "string", (void*) string_parser, offsetof(struct __config, hostid), HOSTID, MAXVAL-1}, { "iv", "string", (void*) string_parser, offsetof(struct __config, iv), "", MAXVAL-1}, { "listen_addr", "string", (void*) string_parser, offsetof(struct __config, listen_addr), "127.0.0.1", MAXVAL-1}, diff --git a/src/cfg.h b/src/cfg.h index 9b44123b..fcc403a4 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -43,6 +43,7 @@ struct __config { int session_timeout; char piler_header_field[MAXVAL]; + char extra_to_field[MAXVAL]; unsigned char key[KEYLEN]; unsigned char iv[MAXVAL]; diff --git a/src/config.h b/src/config.h index 495a128d..877e93ce 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "0.1.22" -#define BUILD 727 +#define BUILD 728 #define HOSTID "mailarchiver" diff --git a/src/parser.c b/src/parser.c index 0c9827cc..a7825748 100644 --- a/src/parser.c +++ b/src/parser.c @@ -348,6 +348,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int else if(strncasecmp(buf, "Recipient:", strlen("Recipient:")) == 0) state->message_state = MSG_RECIPIENT; else if(strncasecmp(buf, "Date:", strlen("Date:")) == 0 && sdata->sent == 0) sdata->sent = parse_date_header(buf); else if(strncasecmp(buf, "Received:", strlen("Received:")) == 0) state->message_state = MSG_RECEIVED; + else if(cfg->extra_to_field[0] != '\0' && strncasecmp(buf, cfg->extra_to_field, strlen(cfg->extra_to_field)) == 0) state->message_state = MSG_TO; if(state->message_state == MSG_MESSAGE_ID && state->message_id[0] == 0){ p = strchr(buf+11, ' ');