From 4291ab502e6d4343c4903d054dd5b7d3e868836b Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Fri, 3 Jan 2025 14:27:36 +0000 Subject: [PATCH] Add option to copy From: to Reply-To: The replyto boolean causes the original From: header to be copied to Reply-To:, so that emails can be accepted from senders that enforce DMARC policies. --- ChangeLog | 1 + TUNABLES.md | 6 ++++++ include/do_all_the_voodoo_here.h | 2 +- src/do_all_the_voodoo_here.c | 9 ++++++++- src/mlmmj-process.c | 8 +++++--- tests/mlmmj-receive.in | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 56ac4f6d..bd4bb7b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 1.5.0 + o Add option to copy From: to Reply-To: (Graham Leggett) o remove contrib/pymime o remove contrib/foot_filter o granular access rejection message diff --git a/TUNABLES.md b/TUNABLES.md index f78c0993..5be5ec63 100644 --- a/TUNABLES.md +++ b/TUNABLES.md @@ -66,6 +66,12 @@ entire content is used as value, it's marked "text". The prefix for the Subject: line of mails to the list. This will alter the Subject: line, and add a prefix if it's not present elsewhere. + * replyto (boolean) + + When this file is present, the From: line of mails will be added as a + Reply-To: header. This allows the mail to be delivered safely when DMARC + protected emails are received from the list. + * owner (list) The emailaddresses in this file (1 pr. line) will get mails to diff --git a/include/do_all_the_voodoo_here.h b/include/do_all_the_voodoo_here.h index d4a7cfde..0111eb44 100644 --- a/include/do_all_the_voodoo_here.h +++ b/include/do_all_the_voodoo_here.h @@ -29,4 +29,4 @@ bool findit(const char *line, const strlist *headers); void getinfo(const char *line, struct mailhdr *readhdrs); int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, const strlist *delhdrs, struct mailhdr *readhdrs, - strlist *allhdrs, const char *subjectprefix); + strlist *allhdrs, const char *subjectprefix, int replyto); diff --git a/src/do_all_the_voodoo_here.c b/src/do_all_the_voodoo_here.c index 496924e6..2e58e178 100644 --- a/src/do_all_the_voodoo_here.c +++ b/src/do_all_the_voodoo_here.c @@ -70,7 +70,7 @@ void getinfo(const char *line, struct mailhdr *readhdrs) int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, const strlist *delhdrs, struct mailhdr *readhdrs, - strlist *allhdrs, const char *prefix) + strlist *allhdrs, const char *prefix, int replyto) { char *hdrline, *unfolded, *unqp; bool hdrsadded = false; @@ -144,6 +144,13 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, if(!delhdrs || !findit(hdrline, delhdrs)) dprintf(outfd, "%s", unfolded); + /* Should Reply-To be added? */ + if(replyto) { + if(strncasecmp(hdrline, "From:", 5) == 0) { + dprintf(outfd, "Reply-To:%s\n", hdrline + 5); + } + } + free(hdrline); free(unfolded); } diff --git a/src/mlmmj-process.c b/src/mlmmj-process.c index 5dba341d..7fdacd13 100644 --- a/src/mlmmj-process.c +++ b/src/mlmmj-process.c @@ -225,7 +225,7 @@ int main(int argc, char **argv) int i, opt, moderated = 0, send = 0; enum modreason modreason; int hdrfd, footfd, rawmailfd, donemailfd, omitfd; - bool addr_in_to_or_cc, notmetoo; + bool addr_in_to_or_cc, notmetoo, replyto; bool findaddress = false, intocc = false, noprocess = false; int maxmailsize = 0; bool subonlypost, modonlypost, modnonsubposts, foundaddr = false; @@ -342,9 +342,11 @@ int main(int argc, char **argv) subjectprefix = ctrlvalue(ml.ctrlfd, "prefix"); + replyto = statctrl(ml.ctrlfd, "replyto"); + if(do_all_the_voodoo_here(rawmailfd, donemailfd, hdrfd, footfd, delheaders, readhdrs, - &allheaders, subjectprefix) < 0) { + &allheaders, subjectprefix, replyto) < 0) { log_error(LOG_ARGS, "Error in do_all_the_voodoo_here"); exit(EXIT_FAILURE); } @@ -483,7 +485,7 @@ int main(int argc, char **argv) } if(do_all_the_voodoo_here(rawmailfd, donemailfd, -1, -1, delheaders, - NULL, &allheaders, NULL) < 0) { + NULL, &allheaders, NULL, 0) < 0) { log_error(LOG_ARGS, "do_all_the_voodoo_here"); exit(EXIT_FAILURE); } diff --git a/tests/mlmmj-receive.in b/tests/mlmmj-receive.in index 2267d43d..c84a6f55 100644 --- a/tests/mlmmj-receive.in +++ b/tests/mlmmj-receive.in @@ -2655,6 +2655,38 @@ really QUIT EOF atf_check -o file:expected-5.txt sed -e "/^Message-ID:/d; /^Date:/d;" mail-5.txt + + touch list/control/replyto + atf_check -s exit:0 $mlmmjreceive -L list -F > expected-6.txt < +RCPT TO: +DATA +From: bob@test +Reply-To: bob@test +To: test@mlmmjtest +Subject: [plop] + +Let's go, first email +myfooter +really +. +MAIL FROM: +RCPT TO: +DATA +From: bob@test +Reply-To: bob@test +To: test@mlmmjtest +Subject: [plop] + +Let's go, first email +myfooter +really +. +QUIT +EOF + atf_check -o file:expected-6.txt sed -e "/^Message-ID:/d; /^Date:/d;" mail-6.txt } delheaders_body() -- 2.47.2