]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Add option to copy From: to Reply-To: 43/head
authorGraham Leggett <minfrin@sharp.fm>
Fri, 3 Jan 2025 14:27:36 +0000 (14:27 +0000)
committerGraham Leggett <minfrin@sharp.fm>
Fri, 3 Jan 2025 14:27:36 +0000 (14:27 +0000)
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
TUNABLES.md
include/do_all_the_voodoo_here.h
src/do_all_the_voodoo_here.c
src/mlmmj-process.c
tests/mlmmj-receive.in

index 56ac4f6dd03fea6389d9e456d5ae5fe6f9f624fe..bd4bb7b1bc7b5a6623e402697239f711c632661b 100644 (file)
--- 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
index f78c0993f04d00054c7bfaf8791470e3cf29bad4..5be5ec6348d0cbdf0e0c90858dcc713d5be5b1a7 100644 (file)
@@ -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
index d4a7cfde01d7d0710ece173125e482119cbff92a..0111eb440c074229693a28daca249ae7acf99a17 100644 (file)
@@ -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);
index 496924e68ca25f98451afa6913ffffd62142351f..2e58e1786fd732155d42a56bbf39d8434f0a15a6 100644 (file)
@@ -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);
        }
index 5dba341d47a0ba284181972488e65d8cce482a24..7fdacd1372c3d862d41a03af4b6346246765fabd 100644 (file)
@@ -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);
                        }
index 2267d43d5c364974a07b73c4cc16307ca4567f14..c84a6f55e115dd8d600e79b7e9fb058a39b29c2f 100644 (file)
@@ -2655,6 +2655,38 @@ really
 QUIT\r
 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 <nosubject
+       cat >> expected-6.txt <<EOF
+EHLO heloname\r
+MAIL FROM:<test+bounces-6-user=test@mlmmjtest>\r
+RCPT TO:<user@test>\r
+DATA\r
+From: bob@test\r
+Reply-To: bob@test\r
+To: test@mlmmjtest\r
+Subject: [plop]\r
+\r
+Let's go, first email\r
+myfooter\r
+really\r
+.\r
+MAIL FROM:<test+bounces-6-user2=test@mlmmjtest>\r
+RCPT TO:<user2@test>\r
+DATA\r
+From: bob@test\r
+Reply-To: bob@test\r
+To: test@mlmmjtest\r
+Subject: [plop]\r
+\r
+Let's go, first email\r
+myfooter\r
+really\r
+.\r
+QUIT\r
+EOF
+       atf_check -o file:expected-6.txt sed -e "/^Message-ID:/d; /^Date:/d;" mail-6.txt
 }
 
 delheaders_body()