BSD 4_4_Lite1 release
[unix-history] / usr / src / usr.sbin / sendmail / src / savemail.c
index 3f40fa8..6467def 100644 (file)
@@ -1,17 +1,43 @@
 /*
  * Copyright (c) 1983 Eric P. Allman
 /*
  * Copyright (c) 1983 Eric P. Allman
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)savemail.c 6.38 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 8.28 (Berkeley) 3/11/94";
 #endif /* not lint */
 
 #endif /* not lint */
 
-# include <pwd.h>
 # include "sendmail.h"
 # include "sendmail.h"
+# include <pwd.h>
 
 /*
 **  SAVEMAIL -- Save mail on error
 
 /*
 **  SAVEMAIL -- Save mail on error
@@ -43,6 +69,10 @@ static char sccsid[] = "@(#)savemail.c       6.38 (Berkeley) %G%";
 # define ESM_PANIC     6       /* leave the locked queue/transcript files */
 # define ESM_DONE      7       /* the message is successfully delivered */
 
 # define ESM_PANIC     6       /* leave the locked queue/transcript files */
 # define ESM_DONE      7       /* the message is successfully delivered */
 
+# ifndef _PATH_VARTMP
+#  define _PATH_VARTMP "/usr/tmp/"
+# endif
+
 
 savemail(e)
        register ENVELOPE *e;
 
 savemail(e)
        register ENVELOPE *e;
@@ -51,16 +81,19 @@ savemail(e)
        register FILE *fp;
        int state;
        auto ADDRESS *q = NULL;
        register FILE *fp;
        int state;
        auto ADDRESS *q = NULL;
+       register char *p;
+       MCI mcibuf;
        char buf[MAXLINE+1];
        extern struct passwd *getpwnam();
        char buf[MAXLINE+1];
        extern struct passwd *getpwnam();
-       register char *p;
        extern char *ttypath();
        typedef int (*fnptr)();
        extern char *ttypath();
        typedef int (*fnptr)();
+       extern bool writable();
 
        if (tTd(6, 1))
        {
 
        if (tTd(6, 1))
        {
-               printf("\nsavemail, errormode = %c, id = %s\n  e_from=",
-                       e->e_errormode, e->e_id == NULL ? "NONE" : e->e_id);
+               printf("\nsavemail, errormode = %c, id = %s, ExitStat = %d\n  e_from=",
+                       e->e_errormode, e->e_id == NULL ? "NONE" : e->e_id,
+                       ExitStat);
                printaddr(&e->e_from, FALSE);
        }
 
                printaddr(&e->e_from, FALSE);
        }
 
@@ -70,17 +103,16 @@ savemail(e)
                return;
        }
 
                return;
        }
 
-       e->e_flags &= ~EF_FATALERRS;
-
        /*
        **  In the unhappy event we don't know who to return the mail
        **  to, make someone up.
        */
 
        /*
        **  In the unhappy event we don't know who to return the mail
        **  to, make someone up.
        */
 
-       if (CurEnv->e_returnto == NULL)
+       if (e->e_from.q_paddr == NULL)
        {
        {
-               CurEnv->e_returnto = parse("root", (ADDRESS *) NULL, 0);
-               if (CurEnv->e_returnto == NULL)
+               e->e_sender = "Postmaster";
+               if (parseaddr(e->e_sender, &e->e_from,
+                             RF_COPYPARSE|RF_SENDERADDR, '\0', NULL, e) == NULL)
                {
                        syserr("553 Cannot parse Postmaster!");
                        ExitStat = EX_SOFTWARE;
                {
                        syserr("553 Cannot parse Postmaster!");
                        ExitStat = EX_SOFTWARE;
@@ -212,33 +244,48 @@ savemail(e)
                        **      joe@x, which gives a response, etc.  Also force
                        **      the mail to be delivered even if a version of
                        **      it has already been sent to the sender.
                        **      joe@x, which gives a response, etc.  Also force
                        **      the mail to be delivered even if a version of
                        **      it has already been sent to the sender.
+                       **
+                       **  If this is a configuration or local software
+                       **      error, send to the local postmaster as well,
+                       **      since the originator can't do anything
+                       **      about it anyway.  Note that this is a full
+                       **      copy of the message (intentionally) so that
+                       **      the Postmaster can forward things along.
                        */
 
                        */
 
+                       if (ExitStat == EX_CONFIG || ExitStat == EX_SOFTWARE)
+                       {
+                               (void) sendtolist("postmaster",
+                                         NULLADDR, &e->e_errorqueue, e);
+                       }
                        if (strcmp(e->e_from.q_paddr, "<>") != 0)
                        if (strcmp(e->e_from.q_paddr, "<>") != 0)
+                       {
                                (void) sendtolist(e->e_from.q_paddr,
                                (void) sendtolist(e->e_from.q_paddr,
-                                         (ADDRESS *) NULL,
-                                         &e->e_errorqueue, e);
+                                         NULLADDR, &e->e_errorqueue, e);
+                       }
 
 
-                       /* deliver a cc: to the postmaster if desired */
-                       if (PostMasterCopy != NULL)
-                       {
-                               auto ADDRESS *rlist = NULL;
+                       /*
+                       **  Deliver a non-delivery report to the
+                       **  Postmaster-designate (not necessarily
+                       **  Postmaster).  This does not include the
+                       **  body of the message, for privacy reasons.
+                       **  You really shouldn't need this.
+                       */
 
 
-                               (void) sendtolist(PostMasterCopy,
-                                                 (ADDRESS *) NULL,
-                                                 &rlist, e);
-                               (void) returntosender(e->e_message,
-                                                     rlist, FALSE, e);
-                       }
-                       q = e->e_errorqueue;
+                       e->e_flags |= EF_PM_NOTIFY;
+
+                       /* check to see if there are any good addresses */
+                       for (q = e->e_errorqueue; q != NULL; q = q->q_next)
+                               if (!bitset(QBADADDR|QDONTSEND, q->q_flags))
+                                       break;
                        if (q == NULL)
                        {
                                /* this is an error-error */
                                state = ESM_POSTMASTER;
                                break;
                        }
                        if (q == NULL)
                        {
                                /* this is an error-error */
                                state = ESM_POSTMASTER;
                                break;
                        }
-                       if (returntosender(e->e_message,
-                                          q, (e->e_class >= 0), e) == 0)
+                       if (returntosender(e->e_message, e->e_errorqueue,
+                                          (e->e_class >= 0), e) == 0)
                        {
                                state = ESM_DONE;
                                break;
                        {
                                state = ESM_DONE;
                                break;
@@ -309,7 +356,9 @@ savemail(e)
                                e->e_to = buf;
                                q = NULL;
                                (void) sendtolist(buf, &e->e_from, &q, e);
                                e->e_to = buf;
                                q = NULL;
                                (void) sendtolist(buf, &e->e_from, &q, e);
-                               if (deliver(e, q) == 0)
+                               if (q != NULL &&
+                                   !bitset(QBADADDR, q->q_flags) &&
+                                   deliver(e, q) == 0)
                                        state = ESM_DONE;
                                else
                                        state = ESM_MAIL;
                                        state = ESM_DONE;
                                else
                                        state = ESM_MAIL;
@@ -332,18 +381,31 @@ savemail(e)
                                break;
                        }
 
                                break;
                        }
 
-                       fp = dfopen("/usr/tmp/dead.letter", "a");
+                       strcpy(buf, _PATH_VARTMP);
+                       strcat(buf, "dead.letter");
+                       if (!writable(buf, NULLADDR, SFF_NOSLINK))
+                       {
+                               state = ESM_PANIC;
+                               break;
+                       }
+                       fp = dfopen(buf, O_WRONLY|O_CREAT|O_APPEND, FileMode);
                        if (fp == NULL)
                        {
                                state = ESM_PANIC;
                                break;
                        }
 
                        if (fp == NULL)
                        {
                                state = ESM_PANIC;
                                break;
                        }
 
-                       putfromline(fp, FileMailer, e);
-                       (*e->e_puthdr)(fp, FileMailer, e);
-                       putline("\n", fp, FileMailer);
-                       (*e->e_putbody)(fp, FileMailer, e);
-                       putline("\n", fp, FileMailer);
+                       bzero(&mcibuf, sizeof mcibuf);
+                       mcibuf.mci_out = fp;
+                       mcibuf.mci_mailer = FileMailer;
+                       if (bitnset(M_7BITS, FileMailer->m_flags))
+                               mcibuf.mci_flags |= MCIF_7BIT;
+
+                       putfromline(&mcibuf, e);
+                       (*e->e_puthdr)(&mcibuf, e);
+                       putline("\n", &mcibuf);
+                       (*e->e_putbody)(&mcibuf, e, NULL);
+                       putline("\n", &mcibuf);
                        (void) fflush(fp);
                        state = ferror(fp) ? ESM_PANIC : ESM_DONE;
                        (void) xfclose(fp, "savemail", "/usr/tmp/dead.letter");
                        (void) fflush(fp);
                        state = ferror(fp) ? ESM_PANIC : ESM_DONE;
                        (void) xfclose(fp, "savemail", "/usr/tmp/dead.letter");
@@ -356,8 +418,7 @@ savemail(e)
 
                  case ESM_PANIC:
                        /* leave the locked queue & transcript files around */
 
                  case ESM_PANIC:
                        /* leave the locked queue & transcript files around */
-                       syserr("554 savemail: cannot save rejected email anywhere");
-                       exit(EX_SOFTWARE);
+                       syserr("!554 savemail: cannot save rejected email anywhere");
                }
        }
 }
                }
        }
 }
@@ -395,11 +456,13 @@ returntosender(msg, returnq, sendbody, e)
        extern putheader(), errbody();
        register ENVELOPE *ee;
        ENVELOPE *oldcur = CurEnv;
        extern putheader(), errbody();
        register ENVELOPE *ee;
        ENVELOPE *oldcur = CurEnv;
-       extern ENVELOPE *newenvelope();
        ENVELOPE errenvelope;
        static int returndepth;
        register ADDRESS *q;
 
        ENVELOPE errenvelope;
        static int returndepth;
        register ADDRESS *q;
 
+       if (returnq == NULL)
+               return (-1);
+
        if (msg == NULL)
                msg = "Unable to deliver mail";
 
        if (msg == NULL)
                msg = "Unable to deliver mail";
 
@@ -421,6 +484,7 @@ returntosender(msg, returnq, sendbody, e)
 
        SendBody = sendbody;
        define('g', e->e_from.q_paddr, e);
 
        SendBody = sendbody;
        define('g', e->e_from.q_paddr, e);
+       define('u', NULL, e);
        ee = newenvelope(&errenvelope, e);
        define('a', "\201b", ee);
        define('r', "internal", ee);
        ee = newenvelope(&errenvelope, e);
        define('a', "\201b", ee);
        define('r', "internal", ee);
@@ -428,21 +492,24 @@ returntosender(msg, returnq, sendbody, e)
        define('_', "localhost", ee);
        ee->e_puthdr = putheader;
        ee->e_putbody = errbody;
        define('_', "localhost", ee);
        ee->e_puthdr = putheader;
        ee->e_putbody = errbody;
-       ee->e_flags |= EF_RESPONSE;
+       ee->e_flags |= EF_RESPONSE|EF_METOO;
        if (!bitset(EF_OLDSTYLE, e->e_flags))
                ee->e_flags &= ~EF_OLDSTYLE;
        ee->e_sendqueue = returnq;
        if (!bitset(EF_OLDSTYLE, e->e_flags))
                ee->e_flags &= ~EF_OLDSTYLE;
        ee->e_sendqueue = returnq;
-       ee->e_msgsize = e->e_msgsize + ERRORFUDGE;
-       openxscript(ee);
+       ee->e_msgsize = ERRORFUDGE;
+       if (!NoReturn)
+               ee->e_msgsize += e->e_msgsize;
+       initsys(ee);
        for (q = returnq; q != NULL; q = q->q_next)
        {
        for (q = returnq; q != NULL; q = q->q_next)
        {
-               if (bitset(QDONTSEND, q->q_flags))
+               if (bitset(QBADADDR, q->q_flags))
                        continue;
 
                        continue;
 
-               ee->e_nrcpts++;
+               if (!bitset(QDONTSEND, q->q_flags))
+                       ee->e_nrcpts++;
 
                if (!DontPruneRoutes && pruneroute(q->q_paddr))
 
                if (!DontPruneRoutes && pruneroute(q->q_paddr))
-                       parseaddr(q->q_paddr, q, 0, '\0', NULL, e);
+                       parseaddr(q->q_paddr, q, RF_COPYPARSE, '\0', NULL, e);
 
                if (q->q_alias == NULL)
                        addheader("To", q->q_paddr, ee);
 
                if (q->q_alias == NULL)
                        addheader("To", q->q_paddr, ee);
@@ -456,10 +523,20 @@ returntosender(msg, returnq, sendbody, e)
 
        (void) sprintf(buf, "Returned mail: %s", msg);
        addheader("Subject", buf, ee);
 
        (void) sprintf(buf, "Returned mail: %s", msg);
        addheader("Subject", buf, ee);
+       if (SendMIMEErrors)
+       {
+               addheader("MIME-Version", "1.0", ee);
+               (void) sprintf(buf, "%s.%ld/%s",
+                       ee->e_id, curtime(), MyHostName);
+               ee->e_msgboundary = newstr(buf);
+               (void) sprintf(buf, "multipart/mixed; boundary=\"%s\"",
+                                       ee->e_msgboundary);
+               addheader("Content-Type", buf, ee);
+       }
 
        /* fake up an address header for the from person */
        expand("\201n", buf, &buf[sizeof buf - 1], e);
 
        /* fake up an address header for the from person */
        expand("\201n", buf, &buf[sizeof buf - 1], e);
-       if (parseaddr(buf, &ee->e_from, 1, '\0', NULL, e) == NULL)
+       if (parseaddr(buf, &ee->e_from, RF_COPYALL|RF_SENDERADDR, '\0', NULL, e) == NULL)
        {
                syserr("553 Can't parse myself!");
                ExitStat = EX_SOFTWARE;
        {
                syserr("553 Can't parse myself!");
                ExitStat = EX_SOFTWARE;
@@ -474,6 +551,9 @@ returntosender(msg, returnq, sendbody, e)
        define('x', "Mail Delivery Subsystem", ee);
        eatheader(ee, TRUE);
 
        define('x', "Mail Delivery Subsystem", ee);
        eatheader(ee, TRUE);
 
+       /* mark statistics */
+       markstats(ee, NULLADDR);
+
        /* actually deliver the error message */
        sendall(ee, SM_DEFAULT);
 
        /* actually deliver the error message */
        sendall(ee, SM_DEFAULT);
 
@@ -492,8 +572,7 @@ returntosender(msg, returnq, sendbody, e)
 **     original offending message.
 **
 **     Parameters:
 **     original offending message.
 **
 **     Parameters:
-**             fp -- the output file.
-**             m -- the mailer to output to.
+**             mci -- the mailer connection information.
 **             e -- the envelope we are working in.
 **
 **     Returns:
 **             e -- the envelope we are working in.
 **
 **     Returns:
@@ -503,9 +582,8 @@ returntosender(msg, returnq, sendbody, e)
 **             Outputs the body of an error message.
 */
 
 **             Outputs the body of an error message.
 */
 
-errbody(fp, m, e)
-       register FILE *fp;
-       register struct mailer *m;
+errbody(mci, e)
+       register MCI *mci;
        register ENVELOPE *e;
 {
        register FILE *xfile;
        register ENVELOPE *e;
 {
        register FILE *xfile;
@@ -517,11 +595,50 @@ errbody(fp, m, e)
        if (e->e_parent == NULL)
        {
                syserr("errbody: null parent");
        if (e->e_parent == NULL)
        {
                syserr("errbody: null parent");
-               putline("\n", fp, m);
-               putline("   ----- Original message lost -----\n", fp, m);
+               putline("   ----- Original message lost -----\n", mci);
                return;
        }
 
                return;
        }
 
+       /*
+       **  Output MIME header.
+       */
+
+       if (e->e_msgboundary != NULL)
+       {
+               putline("This is a MIME-encapsulated message", mci);
+               putline("", mci);
+               (void) sprintf(buf, "--%s", e->e_msgboundary);
+               putline(buf, mci);
+               putline("", mci);
+       }
+
+       /*
+       **  Output introductory information.
+       */
+
+       for (q = e->e_parent->e_sendqueue; q != NULL; q = q->q_next)
+               if (bitset(QBADADDR, q->q_flags))
+                       break;
+       if (q == NULL &&
+           !bitset(EF_FATALERRS|EF_SENDRECEIPT, e->e_parent->e_flags))
+       {
+               putline("    **********************************************",
+                       mci);
+               putline("    **      THIS IS A WARNING MESSAGE ONLY      **",
+                       mci);
+               putline("    **  YOU DO NOT NEED TO RESEND YOUR MESSAGE  **",
+                       mci);
+               putline("    **********************************************",
+                       mci);
+               putline("", mci);
+       }
+       sprintf(buf, "The original message was received at %s",
+               arpadate(ctime(&e->e_parent->e_ctime)));
+       putline(buf, mci);
+       expand("from \201_", buf, &buf[sizeof buf - 1], e->e_parent);
+       putline(buf, mci);
+       putline("", mci);
+
        /*
        **  Output error message header (if specified and available).
        */
        /*
        **  Output error message header (if specified and available).
        */
@@ -536,17 +653,17 @@ errbody(fp, m, e)
                                while (fgets(buf, sizeof buf, xfile) != NULL)
                                {
                                        expand(buf, buf, &buf[sizeof buf - 1], e);
                                while (fgets(buf, sizeof buf, xfile) != NULL)
                                {
                                        expand(buf, buf, &buf[sizeof buf - 1], e);
-                                       putline(buf, fp, m);
+                                       putline(buf, mci);
                                }
                                (void) fclose(xfile);
                                }
                                (void) fclose(xfile);
-                               putline("\n", fp, m);
+                               putline("\n", mci);
                        }
                }
                else
                {
                        expand(ErrMsgFile, buf, &buf[sizeof buf - 1], e);
                        }
                }
                else
                {
                        expand(ErrMsgFile, buf, &buf[sizeof buf - 1], e);
-                       putline(buf, fp, m);
-                       putline("\n", fp, m);
+                       putline(buf, mci);
+                       putline("", mci);
                }
        }
 
                }
        }
 
@@ -557,23 +674,31 @@ errbody(fp, m, e)
        printheader = TRUE;
        for (q = e->e_parent->e_sendqueue; q != NULL; q = q->q_next)
        {
        printheader = TRUE;
        for (q = e->e_parent->e_sendqueue; q != NULL; q = q->q_next)
        {
-               if (bitset(QBADADDR, q->q_flags))
+               if (bitset(QBADADDR|QREPORT, q->q_flags))
                {
                        if (printheader)
                        {
                {
                        if (printheader)
                        {
-                               putline("The following addresses failed:\n",
-                                       fp, m);
+                               putline("   ----- The following addresses had delivery problems -----",
+                                       mci);
                                printheader = FALSE;
                        }
                                printheader = FALSE;
                        }
-                       if (q->q_alias != NULL)
-                               sprintf(buf, "\t%s\n", q->q_alias->q_paddr);
+                       strcpy(buf, q->q_paddr);
+                       if (bitset(QBADADDR, q->q_flags))
+                               strcat(buf, "  (unrecoverable error)");
                        else
                        else
-                               sprintf(buf, "\t%s\n", q->q_paddr);
-                       putline(buf, fp, m);
+                               strcat(buf, "  (transient failure)");
+                       putline(buf, mci);
+                       if (q->q_alias != NULL)
+                       {
+                               strcpy(buf, "    (expanded from: ");
+                               strcat(buf, q->q_alias->q_paddr);
+                               strcat(buf, ")");
+                               putline(buf, mci);
+                       }
                }
        }
        if (!printheader)
                }
        }
        if (!printheader)
-               putline("\n", fp, m);
+               putline("\n", mci);
 
        /*
        **  Output transcript of errors
 
        /*
        **  Output transcript of errors
@@ -584,15 +709,15 @@ errbody(fp, m, e)
        if ((xfile = fopen(p, "r")) == NULL)
        {
                syserr("Cannot open %s", p);
        if ((xfile = fopen(p, "r")) == NULL)
        {
                syserr("Cannot open %s", p);
-               putline("   ----- Transcript of session is unavailable -----\n", fp, m);
+               putline("   ----- Transcript of session is unavailable -----\n", mci);
        }
        else
        {
        }
        else
        {
-               putline("   ----- Transcript of session follows -----\n", fp, m);
+               putline("   ----- Transcript of session follows -----\n", mci);
                if (e->e_xfp != NULL)
                        (void) fflush(e->e_xfp);
                while (fgets(buf, sizeof buf, xfile) != NULL)
                if (e->e_xfp != NULL)
                        (void) fflush(e->e_xfp);
                while (fgets(buf, sizeof buf, xfile) != NULL)
-                       putline(buf, fp, m);
+                       putline(buf, mci);
                (void) xfclose(xfile, "errbody xscript", p);
        }
        errno = 0;
                (void) xfclose(xfile, "errbody xscript", p);
        }
        errno = 0;
@@ -603,31 +728,42 @@ errbody(fp, m, e)
 
        if (NoReturn)
                SendBody = FALSE;
 
        if (NoReturn)
                SendBody = FALSE;
+       putline("", mci);
        if (e->e_parent->e_df != NULL)
        {
                if (SendBody)
        if (e->e_parent->e_df != NULL)
        {
                if (SendBody)
-               {
-                       putline("\n", fp, m);
-                       putline("   ----- Unsent message follows -----\n", fp, m);
-                       (void) fflush(fp);
-                       putheader(fp, m, e->e_parent);
-                       putline("\n", fp, m);
-                       putbody(fp, m, e->e_parent);
-               }
+                       putline("   ----- Original message follows -----\n", mci);
                else
                else
+                       putline("   ----- Message header follows -----\n", mci);
+               (void) fflush(mci->mci_out);
+
+               if (e->e_msgboundary != NULL)
                {
                {
-                       putline("\n", fp, m);
-                       putline("  ----- Message header follows -----\n", fp, m);
-                       (void) fflush(fp);
-                       putheader(fp, m, e->e_parent);
+                       putline("", mci);
+                       (void) sprintf(buf, "--%s", e->e_msgboundary);
+                       putline(buf, mci);
+                       putline("Content-Type: message/rfc822", mci);
+                       putline("", mci);
                }
                }
+               putheader(mci, e->e_parent);
+               putline("", mci);
+               if (SendBody)
+                       putbody(mci, e->e_parent, e->e_msgboundary);
+               else
+                       putline("   ----- Message body suppressed -----", mci);
        }
        else
        {
        }
        else
        {
-               putline("\n", fp, m);
-               putline("  ----- No message was collected -----\n", fp, m);
-               putline("\n", fp, m);
+               putline("  ----- No message was collected -----\n", mci);
+       }
+
+       if (e->e_msgboundary != NULL)
+       {
+               putline("", mci);
+               (void) sprintf(buf, "--%s--", e->e_msgboundary);
+               putline(buf, mci);
        }
        }
+       putline("", mci);
 
        /*
        **  Cleanup and exit
 
        /*
        **  Cleanup and exit
@@ -656,7 +792,7 @@ errbody(fp, m, e)
 pruneroute(addr)
        char *addr;
 {
 pruneroute(addr)
        char *addr;
 {
-#ifdef NAMED_BIND
+#if NAMED_BIND
        char *start, *at, *comma;
        char c;
        int rcode;
        char *start, *at, *comma;
        char c;
        int rcode;