[Exim] headers patch for mail filter command

Top Page
Delete this message
Reply to this message
Author: Carlos Villegas
Date:  
To: exim-users
Subject: [Exim] headers patch for mail filter command
This is a multi-part message in MIME format.
--
Hi,

I don't know if there's already a simpler solution. I once searched the
list archives and didn't find one.

Here is a small patch to add a headers argument to the mail filter
command. We needed this to add the proper MIME headers to send messages
in other character set encodings.
For example:

if personal then
     mail subject "Re: $h_subject"
          headers "MIME-Version: 1.0\n\
                   Content-Type: text/plain; charset=\"iso-2022-jp\"\n\
                   Content-Transfer-Encoding: 7bit"
          text "\x1B\\$BF|K\\\\8|\x1B(B"
endif


In this case the message is encoded in a japanese charset (btw, it reads
"nihongo" which means japanese).
Obviously, we don't edit the filter commands directly, we use a custom
tool that takes care of the code conversion and Exim quoting rules. So
that users can enter japanese chars as they normally do.

The patch may not do everything correctly but it seems to work. Please
verify it possibly include it in a future Exim release.

Cheers,

Carlos
--
diff -u -r exim-4.24-orig/src/filter.c exim-4.24-test/src/filter.c
--- exim-4.24-orig/src/filter.c    2003-09-22 17:29:56.000000000 +0900
+++ exim-4.24-test/src/filter.c    2003-11-03 13:09:42.000000000 +0900
@@ -65,6 +65,7 @@
   "from",
   "reply_to",
   "subject",
+  "headers",                /* misc headers to add (cav) */
   "text",
   "file",
   "log",
@@ -90,6 +91,7 @@
        mailarg_index_from,
        mailarg_index_reply_to,
        mailarg_index_subject,
+       mailarg_index_headers,
        mailarg_index_text,         /* text is first after headers */
        mailarg_index_file,         /* between text and expand are filenames */
        mailarg_index_log,
@@ -110,6 +112,7 @@
   offsetof(reply_item, from),
   offsetof(reply_item, reply_to),
   offsetof(reply_item, subject),
+  offsetof(reply_item, headers),
   offsetof(reply_item, text),
   offsetof(reply_item, file),
   offsetof(reply_item, logfile),
@@ -2217,7 +2220,7 @@
             command_list[commands->command]);
           return FF_ERROR;
           }
-        else if (i < mailarg_index_text && c == '\n' && !isspace(p[1]))
+        else if (i < mailarg_index_headers && c == '\n' && !isspace(p[1]) )
           {
           *error_pointer = string_sprintf("\\n not followed by space in "
             "\"%.1024s\" in %s command", string_printing(s),
@@ -2296,7 +2299,7 @@
       addr->next = *generated;
       *generated = addr;
       addr->reply = store_get(sizeof(reply_item));
-      addr->reply->headers = NULL;    /* Can't set that from here (yet?) */
+      addr->reply->headers = commands->args[mailarg_index_headers] == NULL ? NULL : string_copy(commands->args[mailarg_index_headers]);
       addr->reply->from = NULL;
       addr->reply->to = string_copy(to);
       addr->reply->file_expand =
--