[exim-dev] Overriding From header in quota warning

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Michael Haardt
Datum:  
To: exim-dev
Betreff: [exim-dev] Overriding From header in quota warning
Hello,

this patch allows to override the From: header in quota warning
messages. Right now, you would end up with two from headers if
you tried that. Any comments are appreciated.

Michael
----------------------------------------------------------------------
--- src/deliver.c.orig    2005-12-02 13:55:32.000000000 +0100
+++ src/deliver.c    2005-12-02 13:59:03.000000000 +0100
@@ -1399,6 +1399,40 @@




+/******************************************************
+*   Check, if a mail in string contains a From-Header *
+******************************************************/
+
+/*
+Arguments:
+  message     the mail as CS
+
+Returns:      TRUE
+              FALSE no From:-Header present in message
+*/
+
+BOOL
+header_contains_from(const char *message)
+{
+const char *pch=message;
+while (pch[0]!='\0')
+  {
+  if (tolower(pch[0])=='f' && tolower(pch[1])=='r' &&
+      tolower(pch[2])=='o' && tolower(pch[3])=='m')
+    {
+    pch+=4;
+    while (pch[0]==' ' || pch[0]=='\t') pch++;
+    if (pch[0]==':') return TRUE;
+    }
+  else if (pch[0]=='\n') return FALSE; /* end of header */
+  /* eat up line */
+  while (pch[0]!='\n' && pch[0]!='\0') pch++;
+  if (pch[0]=='\n') pch++;
+  }
+return FALSE;
+}
+
+


 /*************************************************
 *   Check the size of a message for a transport  *
@@ -1992,8 +2026,9 @@
       if (errors_reply_to != NULL)
         fprintf(f, "Reply-To: %s\n", errors_reply_to);
       fprintf(f, "Auto-Submitted: auto-replied\n");
-      fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
-        qualify_domain_sender);
+      if (!header_contains_from(CS warn_message))
+        fprintf(f, "From: Mail Delivery System <Mailer-Daemon@%s>\n",
+          qualify_domain_sender);
       fprintf(f, "%s", CS warn_message);


       /* Close and wait for child process to complete, without a timeout. */