+#ifdef DSN
+ /*
+ ** 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/X-delivery-status-2 (Draft of 20 January 1995)", mci);
+ putline("", mci);
+
+ /*
+ ** Output per-message information.
+ */
+
+ /* original envelope id from MAIL FROM: line */
+ if (e->e_parent->e_envid != NULL)
+ {
+ (void) sprintf(buf, "Original-Envelope-Id: %s",
+ xtextify(e->e_parent->e_envid));
+ putline(buf, mci);
+ }
+
+ /* Reporting-MTA: is us (required) */
+ p = e->e_parent->e_from.q_mailer->m_mtatype;
+ if (p == NULL)
+ p = "dns";
+ (void) sprintf(buf, "Reporting-MTA: %s; %s", p, MyHostName);
+ putline(buf, mci);
+
+ /* Received-From-MTA: shows where we got this message from */
+ if (RealHostName != NULL)
+ {
+ /* XXX use $s for type? */
+ p = e->e_parent->e_from.q_mailer->m_mtatype;
+ if (p == NULL)
+ p = "dns";
+ (void) sprintf(buf, "Received-From-MTA: %s; %s",
+ p, RealHostName);
+ putline(buf, mci);
+ }
+
+ /* Arrival-Date: -- when it arrived here */
+ (void) sprintf(buf, "Arrival-Date: %s",
+ arpadate(ctime(&e->e_parent->e_ctime)));
+ 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);
+
+ /* Original-Recipient: -- passed from on high */
+ if (q->q_orcpt != NULL)
+ {
+ (void) sprintf(buf, "Original-Recipient: %s",
+ xtextify(q->q_orcpt));
+ putline(buf, mci);
+ }
+
+ /* Final-Recipient: -- the name from the RCPT command */
+ p = e->e_parent->e_from.q_mailer->m_addrtype;
+ if (p == NULL)
+ p = "rfc822";
+ for (r = q; r->q_alias != NULL; r = r->q_alias)
+ continue;
+ if (strchr(r->q_user, '@') == NULL)
+ (void) sprintf(buf, "Final-Recipient: %s; %s@%s",
+ p, xtextify(r->q_user), MyHostName);
+ else
+ (void) sprintf(buf, "Final-Recipient: %s; %s",
+ p, xtextify(r->q_user));
+ putline(buf, mci);
+
+ /* Action: -- what happened? */
+ if (bitset(QBADADDR, q->q_flags))
+ putline("Action: failure", 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, "5.0.0");
+ else if (bitset(QQUEUEUP, q->q_flags))
+ strcat(buf, "4.0.0");
+ else if (bitset(QRELAYED, q->q_flags))
+ strcat(buf, "6.0.1");
+ else
+ strcat(buf, "2.0.0");
+ putline(buf, mci);
+
+ /* Remote-MTA: -- who was I talking to? */
+ p = q->q_mailer->m_mtatype;
+ if (p == NULL)
+ p = "dns";
+ (void) sprintf(buf, "Remote-MTA: %s; ", p);
+ if (q->q_statmta != NULL)
+ p = q->q_statmta;
+ else if (q->q_host != NULL)
+ p = q->q_host;
+ else
+ p = NULL;
+ if (p != NULL)
+ {
+ strcat(buf, p);
+ p = &buf[strlen(buf) - 1];
+ if (*p == '.')
+ *p = '\0';
+ putline(buf, mci);
+ }
+
+ /* Diagnostic-Code: -- actual result from other end */
+ if (q->q_rstatus != NULL)
+ {
+ p = q->q_mailer->m_diagtype;
+ if (p == NULL)
+ p = "smtp";
+ (void) sprintf(buf, "Diagnostic-Code: %s; %s",
+ p, q->q_rstatus);
+ putline(buf, mci);
+ }
+
+ /* Last-Attempt-Date: -- fine granularity */
+ if (q->q_statdate == (time_t) 0L)
+ q->q_statdate = curtime();
+ (void) sprintf(buf, "Last-Attempt-Date: %s",
+ arpadate(ctime(&q->q_statdate)));
+ putline(buf, mci);
+
+ /* Expiry-Date: -- for delayed messages only */
+ if (bitset(QQUEUEUP, q->q_flags) &&
+ !bitset(QBADADDR, q->q_flags))
+ {
+ time_t xdate;
+
+ xdate = e->e_ctime + TimeOuts.to_q_return[e->e_timeoutclass];
+ sprintf(buf, "Expiry-Date: %s",
+ arpadate(ctime(&xdate)));
+ putline(buf, mci);
+ }
+ }
+ }
+#endif
+