7 /* user requested delivery tracing
11 /* int trace_append(flags, id, stats, rcpt, relay, dsn)
19 /* int trace_flush(flags, queue, id, encoding, sender,
20 /* dsn_envid, dsn_ret)
24 /* const char *encoding;
25 /* const char *sender;
26 /* const char *dsn_envid;
29 /* trace_append() updates the message delivery record that is
30 /* mailed back to the originator. In case of a trace-only
31 /* message, the recipient status is also written to the
34 /* trace_flush() returns the specified message to the specified
35 /* sender, including the message delivery record log that was built
36 /* with vtrace_append().
40 /* The bitwise OR of zero or more of the following (specify
41 /* BOUNCE_FLAG_NONE to request no special processing):
43 /* .IP BOUNCE_FLAG_CLEAN
44 /* Delete the logfile in case of an error (as in: pretend
45 /* that we never even tried to deliver this message).
48 /* The message queue name of the original message file.
50 /* The message queue id.
52 /* The body content encoding: MAIL_ATTR_ENC_{7BIT,8BIT,NONE}.
54 /* The sender envelope address.
56 /* Optional DSN envelope ID.
58 /* Optional DSN return full/headers option.
60 /* Time stamps from different message delivery stages
61 /* and session reuse count.
63 /* Recipient information. See recipient_list(3).
65 /* The host we sent the mail to.
67 /* Delivery status information. See dsn(3).
69 /* A non-zero result means the operation failed.
71 /* Fatal: out of memory.
73 /* Should be replaced by routines with an attribute-value based
74 /* interface instead of an interface that uses a rigid argument list.
78 /* The Secure Mailer license must be distributed with this software.
81 /* IBM T.J. Watson Research
83 /* Yorktown Heights, NY 10598, USA
92 /* Utility library. */
99 #include <mail_params.h>
100 #include <mail_proto.h>
101 #include <log_adhoc.h>
102 #include <rcpt_print.h>
103 #include <dsn_print.h>
106 /* trace_append - append to message delivery record */
108 int trace_append(int flags
, const char *id
, MSG_STATS
*stats
,
109 RECIPIENT
*rcpt
, const char *relay
,
112 VSTRING
*why
= vstring_alloc(100);
117 * User-requested address verification, verbose delivery, or DSN SUCCESS
120 if (strcmp(relay
, NO_RELAY_AGENT
) != 0)
121 vstring_sprintf(why
, "delivery via %s: ", relay
);
122 vstring_strcat(why
, my_dsn
.reason
);
123 my_dsn
.reason
= vstring_str(why
);
125 if (mail_command_client(MAIL_CLASS_PRIVATE
, var_trace_service
,
126 ATTR_TYPE_INT
, MAIL_ATTR_NREQ
, BOUNCE_CMD_APPEND
,
127 ATTR_TYPE_INT
, MAIL_ATTR_FLAGS
, flags
,
128 ATTR_TYPE_STR
, MAIL_ATTR_QUEUEID
, id
,
129 ATTR_TYPE_FUNC
, rcpt_print
, (void *) rcpt
,
130 ATTR_TYPE_FUNC
, dsn_print
, (void *) &my_dsn
,
131 ATTR_TYPE_END
) != 0) {
132 msg_warn("%s: %s service failure", id
, var_trace_service
);
135 if (flags
& DEL_REQ_FLAG_USR_VRFY
)
136 log_adhoc(id
, stats
, rcpt
, relay
, dsn
, my_dsn
.action
);
143 /* trace_flush - deliver delivery record to the sender */
145 int trace_flush(int flags
, const char *queue
, const char *id
,
146 const char *encoding
, const char *sender
,
147 const char *dsn_envid
, int dsn_ret
)
149 if (mail_command_client(MAIL_CLASS_PRIVATE
, var_trace_service
,
150 ATTR_TYPE_INT
, MAIL_ATTR_NREQ
, BOUNCE_CMD_TRACE
,
151 ATTR_TYPE_INT
, MAIL_ATTR_FLAGS
, flags
,
152 ATTR_TYPE_STR
, MAIL_ATTR_QUEUE
, queue
,
153 ATTR_TYPE_STR
, MAIL_ATTR_QUEUEID
, id
,
154 ATTR_TYPE_STR
, MAIL_ATTR_ENCODING
, encoding
,
155 ATTR_TYPE_STR
, MAIL_ATTR_SENDER
, sender
,
156 ATTR_TYPE_STR
, MAIL_ATTR_DSN_ENVID
, dsn_envid
,
157 ATTR_TYPE_INT
, MAIL_ATTR_DSN_RET
, dsn_ret
,
158 ATTR_TYPE_END
) == 0) {