nmh-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-commits] [SCM] The nmh Mail Handling System branch, master, updated


From: Ken Hornstein
Subject: [Nmh-commits] [SCM] The nmh Mail Handling System branch, master, updated. dfa7b4ffa462d4f24016ab4729928dee5ec389bb
Date: Tue, 13 Mar 2012 02:53:27 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The nmh Mail Handling System".

The branch, master has been updated
       via  dfa7b4ffa462d4f24016ab4729928dee5ec389bb (commit)
      from  15e3d453f414fc1b815ec4895960cad312e78ef9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=dfa7b4ffa462d4f24016ab4729928dee5ec389bb


commit dfa7b4ffa462d4f24016ab4729928dee5ec389bb
Author: Ken Hornstein <address@hidden>
Date:   Mon Mar 12 22:52:21 2012 -0400

    New changes: Sender: cannot be blank, Sender: always overrides From:
    for SMTP envelope, and Envelope-From: will cause a Sender: header to be
    output if multiple From: addresses are used.

diff --git a/man/send.man b/man/send.man
index f4fea40..2cd840b 100644
--- a/man/send.man
+++ b/man/send.man
@@ -296,13 +296,20 @@ addresses are permitted in the \*(lqFrom:\*(rq field, but 
a \*(lqSender:\*(rq
 field is required in this case.  Otherwise a \*(lqSender:\*(rq field
 is optional.
 .PP
-When using SMTP for mail submission, the envelope\-from used for SMTP
-transaction is derived from the \*(lqFrom:\*(rq field.  If multiple
-addresses are in the \*(lqFrom:\*(rq field, the address in the
-\*(lqSender\*(rq field is used instead.  This behavior can be overridden
-by using the \*(lqEnvelope\-From:\*(rq field.  When \*(lqEnvelope\-From\*(rq
-appears in the message, its address will be used as the SMTP envelope\-from
-address and the field will be removed from the message.
+If a message with multiple \*(lqFrom:\*(rq
+addresses does
+.B NOT
+include a \*(lqSender:\*(rq field but does include an \*(lqEnvelope\-From:\*(rq
+field, the \*(lqEnvelope\-From:\*(rq field will be used to construct
+a \*(lqSender:\*(rq field.
+.PP
+When using SMTP for mail submission, the envelope\-from used for the SMTP
+transaction is derived from the \*(lqEnvelope\-From:\*(rq field.
+If no \*(lqEnvelope\-From:\*(rq field is present, the \*(lqSender:\*(rq
+field is used.  If neither the \*(lqEnvelope\-From:\*(rq nor the
+\*(lqSender:\*(rq field is present, the \*(lqFrom:\*(rq field is used.
+When \*(lqEnvelope\-From:\*(rq appears in a message
+it will be removed from the final outgoing message.
 .PP
 By using the
 .B \-format
diff --git a/uip/post.c b/uip/post.c
index 79a53aa..c9b4c05 100644
--- a/uip/post.c
+++ b/uip/post.c
@@ -43,8 +43,6 @@
 
 #define FCCS           10      /* max number of fccs allowed */
 
-#define        uptolow(c)      ((isalpha(c) && isupper (c)) ? tolower (c) : c)
-
 /* In the following array of structures, the numeric second field of the
    structures (minchars) is apparently used like this:
 
@@ -158,7 +156,7 @@ struct headers {
 #define        HNIL  0x0100            /* okay for this header not to have 
addrs */
 #define        HIGN  0x0200            /* ignore this header                   
  */
 #define        HDCC  0x0400            /* another undocumented feature         
  */
-#define HONE  0x0800           /* Only one address allowed               */
+#define HONE  0x0800           /* Only (zero or) one address allowed     */
 #define HEFM  0x1000           /* Envelope-From: header                  */
 
 /*
@@ -622,14 +620,13 @@ main (int argc, char **argv)
      * address for SMTP.
      *
      * - If we were given an Envelope-From header, use that.
-     * - If we were given multiple addresses in the From: header, use
-     *   the Sender: address
+     * - If we were given a Sender: address, use that.
      * - Otherwise, use the address on the From: line
      */
 
     if (msgflags & MEFM) {
        envelope = efrom;
-    } else if (fromcount > 1) {
+    } else if (seensender) {
        envelope = sender;
     } else {
        envelope = from;
@@ -739,6 +736,14 @@ putfmt (char *name, char *str, FILE *out)
        if (hdr->flags & HNIL)
            fprintf (out, "%s: %s", name, str);
        else {
+           /*
+            * Sender (or Resent-Sender) can have only one address
+            */
+           if ((msgstate == RESENT) ? (hdr->set & MRSN)
+                                       : (hdr->set & MSND)) {
+               advise (NULL, "%s: field requires one address", name);
+               badmsg++;
+           }
 #ifdef notdef
            advise (NULL, "%s: field requires at least one address", name);
            badmsg++;
@@ -885,18 +890,20 @@ static void
 start_headers (void)
 {
     unsigned char  *cp;
-    char myhost[BUFSIZ], sigbuf[BUFSIZ];
+    char sigbuf[BUFSIZ];
     struct mailname *mp;
 
     myuid = getuid ();
     mygid = getgid ();
     time (&tclock);
 
-    strncpy (from, getlocaladdr(), sizeof(from));
-    strncpy (myhost, LocalName (0), sizeof(myhost));
+    /*
+     * Probably not necessary, but just in case ...
+     */
 
-    for (cp = myhost; *cp; cp++)
-       *cp = uptolow (*cp);
+    from[0] = '\0';
+    efrom[0] = '\0';
+    sender[0] = '\0';
 
     if ((cp = getfullname ()) && *cp) {
        strncpy (sigbuf, cp, sizeof(sigbuf));
@@ -933,12 +940,14 @@ finish_headers (FILE *out)
                advise (NULL, "message has no From: header");
                advise (NULL, "See default components files for examples");
                badmsg++;
+               break;
            }
 
-           if (fromcount > 1 && seensender == 0) {
-               advise (NULL, "A Sender: header is required with multiple "
-                       "From: addresses");
+           if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) {
+               advise (NULL, "A Sender: or Envelope-From: header is required "
+                       "with multiple\nFrom: addresses");
                badmsg++;
+               break;
            }
 
            if (whomsw)
@@ -948,6 +957,23 @@ finish_headers (FILE *out)
            if (msgid)
                fprintf (out, "Message-ID: <address@hidden>\n",
                        (int) getpid (), (long) tclock, LocalName (1));
+           /*
+            * If we have multiple From: addresses, make sure we have an
+            * Sender: header.  If we don't have one, then generate one
+            * from Envelope-From: (which in this case, cannot be blank)
+            */
+
+           if (fromcount > 1 && seensender == 0) {
+               if (efrom[0] == '\0') {
+                   advise (NULL, "Envelope-From cannot be blank when there "
+                           "is multiple From: addresses\nand no Sender: "
+                           "header");
+                   badmsg++;
+               } else {
+                   fprintf (out, "Sender: %s\n", efrom);
+               }
+           }
+
            if (!(msgflags & MVIS))
                fprintf (out, "Bcc: Blind Distribution List: ;\n");
            break;
@@ -965,11 +991,13 @@ finish_headers (FILE *out)
                advise (NULL, "message has no Resent-From: header");
                advise (NULL, "See default components files for examples");
                badmsg++;
+               break;
            }
-           if (fromcount > 1 && seensender == 0) {
-               advise (NULL, "A Resent-Sender: header is required with "
-                       "multiple Resent-From: addresses");
+           if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) {
+               advise (NULL, "A Resent-Sender: or Envelope-From: header is "
+                       "required with multiple\nResent-From: addresses");
                badmsg++;
+               break;
            }
 
            if (whomsw)
@@ -979,6 +1007,23 @@ finish_headers (FILE *out)
            if (msgid)
                fprintf (out, "Resent-Message-ID: <address@hidden>\n",
                        (int) getpid (), (long) tclock, LocalName (1));
+           /*
+            * If we have multiple Resent-From: addresses, make sure we have an
+            * Resent-Sender: header.  If we don't have one, then generate one
+            * from Envelope-From (which in this case, cannot be blank)
+            */
+
+           if (fromcount > 1 && seensender == 0) {
+               if (efrom[0] == '\0') {
+                   advise (NULL, "Envelope-From cannot be blank when there "
+                           "is multiple Resent-From: addresses and no "
+                           "Resent-Sender: header");
+                   badmsg++;
+               } else {
+                   fprintf (out, "Resent-Sender: %s\n", efrom);
+               }
+           }
+
            if (!(msgflags & MVIS))
                fprintf (out, "Resent-Bcc: Blind Re-Distribution List: ;\n");
            break;

-----------------------------------------------------------------------

Summary of changes:
 man/send.man |   21 ++++++++++-----
 uip/post.c   |   79 +++++++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 76 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
The nmh Mail Handling System



reply via email to

[Prev in Thread] Current Thread [Next in Thread]