+ /*
+ ** Output machine-readable version.
+ */
+
+ if (e->e_msgboundary != NULL)
+ {
+ putline("", mci);
+ (void) sprintf(buf, "--%s", e->e_msgboundary);
+ putline(buf, mci);
+ putline("Content-Type: message/delivery-status", mci);
+ putline("", mci);
+
+ /*
+ ** Output per-message information.
+ */
+
+ /* Original-MTS-Type: is optional */
+
+ /* original envelope id from MAIL FROM: line */
+ if (e->e_parent->e_envid != NULL)
+ {
+ (void) sprintf(buf, "Original-Envelope-Id: %s",
+ e->e_parent->e_envid);
+ putline(buf, mci);
+ }
+
+ /* Final-MTS-Type: is optional (always INET?) */
+
+ /* Final-MTA: seems silly -- this is in the From: line */
+ (void) sprintf(buf, "Final-MTA: %s", MyHostName);
+ putline(buf, mci);
+
+ /*
+ ** Output per-address information.
+ */
+
+ for (q = e->e_parent->e_sendqueue; q != NULL; q = q->q_next)
+ {
+ register ADDRESS *r;
+
+ if (!bitset(QBADADDR|QREPORT|QRELAYED, q->q_flags))
+ continue;
+ putline("", mci);
+
+ /* Rcpt: -- the name from the RCPT command */
+ for (r = q; r->q_alias != NULL; r = r->q_alias)
+ continue;
+ (void) sprintf(buf, "Rcpt: %s", r->q_paddr);
+ putline(buf, mci);
+
+ /* Action: -- what happened? */
+ if (bitset(QBADADDR, q->q_flags))
+ putline("Action: failed", mci);
+ else if (bitset(QQUEUEUP, q->q_flags))
+ putline("Action: delayed", mci);
+ else if (bitset(QRELAYED, q->q_flags))
+ putline("Action: relayed", mci);
+ else
+ putline("Action: delivered", mci);
+
+ /* Status: -- what _really_ happened? */
+ strcpy(buf, "Status: ");
+ if (q->q_status != NULL)
+ strcat(buf, q->q_status);
+ else if (bitset(QBADADDR, q->q_flags))
+ strcat(buf, "500");
+ else if (bitset(QQUEUEUP, q->q_flags))
+ strcat(buf, "400");
+ else if (bitset(QRELAYED, q->q_flags))
+ strcat(buf, "601");
+ else
+ strcat(buf, "200");
+ putline(buf, mci);
+
+ /* Date: -- fine granularity */
+ if (q->q_statdate == (time_t) 0L)
+ q->q_statdate = curtime();
+ (void) sprintf(buf, "Date: %s",
+ arpadate(ctime(&q->q_statdate)));
+ putline(buf, mci);
+
+ /* Final-Log-Id: -- why isn't this per-message? */
+ (void) sprintf(buf, "Final-Log-Id: %s", e->e_id);
+ putline(buf, mci);
+
+ /* Original-Rcpt: -- passed from on high */
+ if (q->q_orcpt != NULL)
+ {
+ (void) sprintf(buf, "Original-Rcpt: %s",
+ q->q_orcpt);
+ putline(buf, mci);
+ }
+
+ /* Final-Rcpt: -- if through alias */
+ if (q->q_alias != NULL)
+ {
+ (void) sprintf(buf, "Final-Rcpt: %s",
+ q->q_paddr);
+ putline(buf, mci);
+ }
+
+ /* Final-Status: -- same as Status? XXX */
+
+ /* Remote-MTS-Type: -- always INET? XXX */
+
+ /* Remote-MTA: -- who was I talking to? */
+ if (q->q_statmta != NULL)
+ {
+ (void) sprintf(buf, "Remote-MTA: %s",
+ q->q_statmta);
+ putline(buf, mci);
+ }
+
+ /* Remote-Rcpt: -- same as Final-Rcpt? XXX */
+
+ /* Remote-Status: -- same as Final-Status? XXX */
+ }
+ }
+