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