Changed error message to say that blind lists aren't
[mmh] / uip / post.c
index 813d462..6b07861 100644 (file)
@@ -262,6 +262,7 @@ static char bccfil[BUFSIZ];
 static char from[BUFSIZ];      /* my network address            */
 static char sender[BUFSIZ];    /* my Sender: header             */
 static char efrom[BUFSIZ];     /* my Envelope-From: header      */
+static char fullfrom[BUFSIZ];  /* full contents of From header  */
 static char signature[BUFSIZ]; /* my signature                  */
 static char *filter = NULL;    /* the filter for BCC'ing        */
 static char *subject = NULL;   /* the subject field for BCC'ing */
@@ -708,7 +709,21 @@ putfmt (char *name, char *str, FILE *out)
     }
 
     if ((i = get_header (name, hdrtab)) == NOTOK) {
-       fprintf (out, "%s: %s", name, str);
+       if (strncasecmp (name, "nmh-", 4)) {
+           fprintf (out, "%s: %s", name, str);
+       } else {
+           /* Filter out all Nmh-* headers, because Norm asked.  They
+              should never have reached this point.  Warn about any
+              that are non-empty. */
+           if (strcmp (str, "\n")) {
+               char *newline = strchr (str, '\n');
+               if (newline) *newline = '\0';
+               if (! whomsw) {
+                   advise (NULL, "ignoring header line -- %s: %s", name, str);
+               }
+           }
+       }
+
        return;
     }
 
@@ -839,8 +854,22 @@ putfmt (char *name, char *str, FILE *out)
                else
                    if (mp->m_gname)
                        putgrp (namep, mp->m_gname, out, hdr->flags);
-               if (mp->m_ingrp)
+               if (mp->m_ingrp) {
+                   if (sm_mts == MTS_SENDMAIL_PIPE) {
+                       /* Catch this before sendmail chokes with:
+                          "553 List:; syntax illegal for recipient
+                           addresses".
+                          If we wanted to, we could expand out blind
+                          aliases and put them in Bcc:, but then
+                          they'd have the Blind-Carbon-Copy
+                          indication. */
+                       adios (NULL,
+                              "blind lists not compatible with"
+                              " sendmail/pipe");
+                   }
+
                    grp++;
+               }
                if (putadr (namep, qp, mp, out, hdr->flags))
                    msgflags |= (hdr->set & (MVIS | MINV));
                else
@@ -900,6 +929,23 @@ putfmt (char *name, char *str, FILE *out)
                mnfree (mp);
        }
 
+    /*
+     * If this is a From:/Resent-From: header, save the full thing for
+     * later in case we need it for use when constructing a Bcc draft message
+     */
+
+    if ((msgstate == RESENT) ? (hdr->set & MRFM) : (hdr->set & MFRM)) {
+       strncpy(fullfrom, str, sizeof(fullfrom));
+       fullfrom[sizeof(fullfrom) - 1] = 0;
+       /*
+        * Strip off any trailing newlines
+        */
+
+       while (strlen(fullfrom) > 0 && fullfrom[strlen(fullfrom) - 1] == '\n') {
+           fullfrom[strlen(fullfrom) - 1] = '\0';
+       }
+    }
+
     if (grp > 0 && (hdr->flags & HNGR)) {
        advise (NULL, "%s: field does not allow groups", name);
        badmsg++;
@@ -928,6 +974,7 @@ start_headers (void)
     from[0] = '\0';
     efrom[0] = '\0';
     sender[0] = '\0';
+    fullfrom[0] = '\0';
 
     if ((cp = getfullname ()) && *cp) {
        strncpy (sigbuf, cp, sizeof(sigbuf));
@@ -1281,6 +1328,7 @@ make_bcc_file (int dashstuff)
     if (tfile == NULL) adios("bcc", "unable to create temporary file");
     strncpy (bccfil, tfile, sizeof(bccfil));
 
+    fprintf (out, "From: %s\n", fullfrom);
     fprintf (out, "Date: %s\n", dtime (&tclock, 0));
     if (msgid)
        fprintf (out, "Message-ID: %s\n", message_id (tclock, 0));