nmh-workers
[Top] [All Lists]

[Nmh-workers] 1.1rc3 - add rfc3461 DSN support

2004-08-09 17:56:29
Here's a patch that allows setting rfc3461 Delivery Service Notification
(notify=success,fail,delay ret= and envid=) flags on outbound mail.  I've
added corresponding UA support to the exmh CVS tree already.

I didn't do patches for the manpages or the 'spost' command - am willing
to do so if this first part flies....

--- nmh/h/mf.h.dsn      2003-10-24 16:17:20.000000000 -0400
+++ nmh/h/mf.h  2004-08-07 01:23:13.000000000 -0400
@@ -27,6 +27,10 @@
 # define DONE 1
 #endif
 
+#ifndef NULLCP
+# define NULLCP ((char *) 0)
+#endif
+
 #define        LINESIZ 512
 
 #define        MBXMODE 0600
--- nmh/h/mh.h.dsn      2003-10-24 16:17:20.000000000 -0400
+++ nmh/h/mh.h  2004-08-07 01:53:26.000000000 -0400
@@ -15,6 +15,7 @@
 #define        DONE           1        /* trinary logic                   */
 #define ALL           ""
 #define        Nbby           8        /* number of bits/byte */
+#define NULLCP  ((char *) 0)
 
 #define MAXARGS            1000        /* max arguments to exec                
*/
 #define NFOLDERS    1000       /* max folder arguments on command line */
--- nmh/mts/smtp/smtp.c.dsn     2004-08-07 00:49:59.000000000 -0400
+++ nmh/mts/smtp/smtp.c 2004-08-07 01:32:33.000000000 -0400
@@ -514,9 +514,12 @@ rclient (char *server, char *protocol, c
 #endif /* CYRUS_SASL */
 
 int
-sm_winit (int mode, char *from)
+sm_winit (int mode, char *from, char *ret, char *envid)
 {
     char *smtpcom;
+    char tmpstr[BUFSIZ];
+
+    tmpstr[0] = '\0';
 
 #ifdef MPOP
     if (sm_ispool && !sm_wfp) {
@@ -544,7 +547,18 @@ sm_winit (int mode, char *from)
            break;
     }
 
-    switch (smtalk (SM_MAIL, "%s FROM:<%s>", smtpcom, from)) {
+    if ((ret != NULLCP || envid != NULLCP) && EHLOset ("DSN")) {
+       if (ret != NULLCP && strlen(ret) > 8) ret[8] = '\0';
+       if (ret) sprintf(tmpstr, " RET=%s", ret);
+       if (envid != NULLCP && strlen(envid) > 100) envid[100] = '\0';
+       if (envid) {
+           strcat(tmpstr, " ENVID=");
+           strcat(tmpstr, envid);
+       }
+    }
+
+    switch (smtalk (SM_MAIL, "%s FROM:<%s>%s", smtpcom, from,
+               tmpstr ? tmpstr : "")) {
        case 250: 
            sm_addrs = 0;
            return RP_OK;
@@ -561,11 +575,25 @@ sm_winit (int mode, char *from)
 
 
 int
-sm_wadr (char *mbox, char *host, char *path)
+sm_wadr (char *mbox, char *host, char *path, char *notify)
 {
-    switch (smtalk (SM_RCPT, host && *host ? "RCPT TO:<%s%s(_at_)%s>"
-                                          : "RCPT TO:<%s%s>",
-                            path ? path : "", mbox, host)) {
+char tmpstr[BUFSIZ];
+
+    tmpstr[0] = '\0';
+
+    if (notify != NULLCP && EHLOset ("DSN")) {
+       if (strlen(notify) > 28) {
+           notify[28] = '\0';
+       }
+       sprintf(tmpstr, host && *host ? " NOTIFY=%s ORCPT=rfc822;%s%s(_at_)%s" :
+           " NOTIFY=%s ORCPT=rfc822;%s%s", notify, path ? path : "", mbox,
+           host);
+    }
+
+    switch (smtalk (SM_RCPT, host && *host ? "RCPT TO:<%s%s(_at_)%s>%s"
+                                          : "RCPT TO:<%s%s>%s",
+                            path ? path : "", mbox, host,
+                            tmpstr ? tmpstr : "")) {
        case 250: 
        case 251: 
            sm_addrs++;
--- nmh/mts/smtp/smtp.h.dsn     2003-10-24 16:17:22.000000000 -0400
+++ nmh/mts/smtp/smtp.h 2004-08-07 01:47:35.000000000 -0400
@@ -22,8 +22,8 @@ struct smtp {
  */
 /* int client (); */
 int sm_init (char *, char *, int, int, int, int, int, int, char *, char *);
-int sm_winit (int, char *);
-int sm_wadr (char *, char *, char *);
+int sm_winit (int, char *, char *, char *);
+int sm_wadr (char *, char *, char *, char *);
 int sm_waend (void);
 int sm_wtxt (char *, int);
 int sm_wtend (void);
--- nmh/uip/post.c.dsn  2003-10-24 16:17:27.000000000 -0400
+++ nmh/uip/post.c      2004-08-07 01:41:56.000000000 -0400
@@ -144,6 +144,12 @@ static struct swit switches[] = {
     { "saslmech", SASLminc(-5) },
 #define USERSW                   39
     { "user", SASLminc(-4) },
+#define NOTIFYSW                 40
+    { "notify option", 6 },
+#define RETSW                   41
+    { "ret option", 3 },
+#define ENVIDSW                         42
+    { "envid id", 5 },
     { NULL, 0 }
 };
 
@@ -294,6 +300,8 @@ static char *fill_in = NULL;
 static char *partno = NULL;
 static int queued = 0;
 
+static char *notify = NULLCP, *ret = NULLCP, *envid = NULLCP;
+
 extern boolean  draft_from_masquerading;  /* defined in mts.c */
 
 /*
@@ -550,6 +558,19 @@ main (int argc, char **argv)
                    if (!(user = *argp++) || *user == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
                    continue;
+
+               case RETSW:
+                   if (!(ret = *argp++) || *ret == '-')
+                       adios (NULL, "missing argument to %s", argp[-2]);
+                   continue;
+               case ENVIDSW:
+                   if (!(envid = *argp++) || *envid == '-')
+                       adios (NULL, "missing argument to %s", argp[-2]);
+                   continue;
+               case NOTIFYSW:
+                   if (!(notify = *argp++) || *notify == '-')
+                       adios (NULL, "missing argument to %s", argp[-2]);
+                   continue;
            }
        }
        if (msg)
@@ -1441,7 +1462,7 @@ post (char *file, int bccque, int talk)
     if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose,
                                    snoop, onex, queued, sasl, saslmech,
                                    user))
-           || rp_isbad (retval = sm_winit (smtpmode, from)))
+           || rp_isbad (retval = sm_winit (smtpmode, from, ret, envid)))
        die (NULL, "problem initializing server; %s", rp_string (retval));
 
     do_addresses (bccque, talk && verbose);
@@ -1479,7 +1500,7 @@ verify_all_addresses (int talk)
     if (!whomsw || checksw)
        if (rp_isbad (retval = sm_init (clientsw, serversw, 0, 0, snoop, 0,
                                        0, 0, 0, 0))
-               || rp_isbad (retval = sm_winit (smtpmode, from)))
+               || rp_isbad (retval = sm_winit (smtpmode, from, ret, envid)))
            die (NULL, "problem initializing server; %s", rp_string (retval));
 
     if (talk && !whomsw)
@@ -1550,7 +1571,7 @@ do_an_address (struct mailname *lp, int 
     fflush (stdout);
 
     switch (retval = sm_wadr (mbox, host,
-                        lp->m_type != UUCPHOST ? lp->m_path : NULL)) {
+                        lp->m_type != UUCPHOST ? lp->m_path : NULL, notify)) {
        case RP_OK: 
            if (talk)
                printf ("address ok\n");
--- nmh/uip/send.c.dsn  2003-10-24 16:17:40.000000000 -0400
+++ nmh/uip/send.c      2004-08-07 01:44:46.000000000 -0400
@@ -104,6 +104,12 @@ static struct swit switches[] = {
     { "user", SASLminc(-4) },
 #define ATTACHSW              40
     { "attach", 6 },
+#define NOTIFYSW              41
+    { "notify option", 6 },
+#define RETSW                 42
+    { "ret option", 3 },
+#define ENVIDSW               43
+    { "envid id", 5 },
     { NULL, 0 }
 };
 
@@ -270,6 +276,9 @@ main (int argc, char **argv)
                case SERVSW: 
                case SASLMECHSW:
                case USERSW:
+               case RETSW:
+               case ENVIDSW:
+               case NOTIFYSW:
                    vec[vecp++] = --cp;
                    if (!(cp = *argp++) || *cp == '-')
                        adios (NULL, "missing argument to %s", argp[-2]);
--- nmh/uip/whatnowsbr.c.dsn    2003-10-24 16:17:40.000000000 -0400
+++ nmh/uip/whatnowsbr.c        2004-08-07 03:37:04.762741565 -0400
@@ -1005,6 +1005,12 @@ static struct swit  sendswitches[] = {
     { "user", SASLminc(-4) },
 #define SNDATTACHSW       39
     { "attach file", 6 },
+#define NOTIFYSW         40
+    { "notify option", 6 },
+#define RETSW            41
+    { "ret option", 3 },
+#define ENVIDSW          42
+    { "envid id", 5 },
     { NULL, 0 }
 };
 
@@ -1167,6 +1173,9 @@ sendit (char *sp, char **arg, char *file
                case SERVSW:
                case SASLMECHSW:
                case USERSW:
+               case RETSW:
+               case ENVIDSW:
+               case NOTIFYSW:
                    vec[vecp++] = --cp;
                    if (!(cp = *argp++) || *cp == '-') {
                        advise (NULL, "missing argument to %s", argp[-2]);


Attachment: pgp8AvJ4Zf4Gf.pgp
Description: PGP signature

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
http://lists.nongnu.org/mailman/listinfo/nmh-workers
<Prev in Thread] Current Thread [Next in Thread>