1 /* $NetBSD: indirect.c,v 1.1.1.1 2009/06/23 10:08:48 tron Exp $ */
2
3 /*++
4 /* NAME
5 /* indirect 3
6 /* SUMMARY
7 /* indirect delivery
8 /* SYNOPSIS
9 /* #include "local.h"
10 /*
11 /* void deliver_indirect(state)
12 /* LOCAL_STATE state;
13 /* char *recipient;
14 /* DESCRIPTION
15 /* deliver_indirect() delivers a message via the message
16 /* forwarding service, with duplicate filtering up to a
17 /* configurable number of recipients.
18 /*
19 /* Arguments:
20 /* .IP state
21 /* The attributes that specify the message, sender and more.
22 /* A table with the results from expanding aliases or lists.
23 /* CONFIGURATION VARIABLES
24 /* duplicate_filter_limit, duplicate filter size limit
25 /* DIAGNOSTICS
26 /* The result is non-zero when the operation should be tried again.
27 /* LICENSE
28 /* .ad
29 /* .fi
30 /* The Secure Mailer license must be distributed with this software.
31 /* AUTHOR(S)
32 /* Wietse Venema
33 /* IBM T.J. Watson Research
34 /* P.O. Box 704
35 /* Yorktown Heights, NY 10598, USA
36 /*--*/
37
38 /* System library. */
39
40 #include <sys_defs.h>
41 #include <unistd.h>
42
43 /* Utility library. */
44
45 #include <msg.h>
46 #include <htable.h>
47
48 /* Global library. */
49
50 #include <mail_params.h>
51 #include <bounce.h>
52 #include <defer.h>
53 #include <been_here.h>
54 #include <sent.h>
55
56 /* Application-specific. */
57
58 #include "local.h"
59
60 /* deliver_indirect - deliver mail via forwarding service */
61
deliver_indirect(LOCAL_STATE state)62 int deliver_indirect(LOCAL_STATE state)
63 {
64
65 /*
66 * Suppress duplicate expansion results. Add some sugar to the name to
67 * avoid collisions with other duplicate filters. Allow the user to
68 * specify an upper bound on the size of the duplicate filter, so that we
69 * can handle huge mailing lists with millions of recipients.
70 */
71 if (msg_verbose)
72 msg_info("deliver_indirect: %s", state.msg_attr.rcpt.address);
73 if (been_here(state.dup_filter, "indirect %s",
74 state.msg_attr.rcpt.address))
75 return (0);
76
77 /*
78 * Don't forward a trace-only request.
79 */
80 if (DEL_REQ_TRACE_ONLY(state.request->flags)) {
81 dsb_simple(state.msg_attr.why, "2.0.0", "forwards to %s",
82 state.msg_attr.rcpt.address);
83 return (sent(BOUNCE_FLAGS(state.request), SENT_ATTR(state.msg_attr)));
84 }
85
86 /*
87 * Send the address to the forwarding service. Inherit the delivered
88 * attribute from the alias or from the .forward file owner.
89 */
90 if (forward_append(state.msg_attr)) {
91 dsb_simple(state.msg_attr.why, "4.3.0", "unable to forward message");
92 return (defer_append(BOUNCE_FLAGS(state.request),
93 BOUNCE_ATTR(state.msg_attr)));
94 }
95 return (0);
96 }
97