5
/* delivery of unknown recipients
9
/* int deliver_unknown(state, usr_attr)
11
/* USER_ATTR usr_attr;
13
/* deliver_unknown() delivers a message for unknown recipients.
15
/* If an alternative message transport is specified via the
16
/* fallback_transport parameter, delivery is delegated to the
19
/* If an alternative address is specified via the luser_relay
20
/* configuration parameter, mail is forwarded to that address.
22
/* Otherwise the recipient is bounced.
24
/* The luser_relay parameter is subjected to $name expansion of
25
/* the standard message attributes: $user, $home, $shell, $domain,
26
/* $recipient, $mailbox, $extension, $recipient_delimiter, not
27
/* all of which actually make sense.
31
/* Message delivery attributes (sender, recipient etc.).
32
/* Attributes describing alias, include or forward expansion.
33
/* A table with the results from expanding aliases or lists.
34
/* A table with delivered-to: addresses taken from the message.
36
/* Attributes describing user rights and environment.
38
/* The result status is non-zero when delivery should be tried again.
42
/* The Secure Mailer license must be distributed with this software.
45
/* IBM T.J. Watson Research
47
/* Yorktown Heights, NY 10598, USA
55
#ifdef STRCASECMP_IN_STRINGS_H
59
/* Utility library. */
62
#include <stringops.h>
68
#include <been_here.h>
69
#include <mail_params.h>
70
#include <mail_proto.h>
72
#include <mail_addr.h>
75
/* Application-specific. */
79
/* deliver_unknown - delivery for unknown recipients */
81
int deliver_unknown(LOCAL_STATE state, USER_ATTR usr_attr)
83
char *myname = "deliver_unknown";
85
VSTRING *expand_luser;
88
* Make verbose logging easier to understand.
92
MSG_LOG_STATE(myname, state);
95
* DUPLICATE/LOOP ELIMINATION
97
* Don't deliver the same user twice.
99
if (been_here(state.dup_filter, "%s %s", myname, state.msg_attr.local))
103
* The fall-back transport specifies a delivery machanism that handles
104
* users not found in the aliases or UNIX passwd databases.
106
if (*var_fallback_transport)
107
return (deliver_pass(MAIL_CLASS_PRIVATE, var_fallback_transport,
108
state.request, state.msg_attr.orig_rcpt,
109
state.msg_attr.recipient, -1L));
112
* Subject the luser_relay address to $name expansion, disable
113
* propagation of unmatched address extension, and re-inject the address
114
* into the delivery machinery. Do not give special treatment to "|stuff"
117
if (*var_luser_relay) {
118
state.msg_attr.unmatched = 0;
119
expand_luser = vstring_alloc(100);
120
local_expand(expand_luser, var_luser_relay, &state, &usr_attr, (char *) 0);
121
status = deliver_resolve_addr(state, usr_attr, vstring_str(expand_luser));
122
vstring_free(expand_luser);
127
* If no alias was found for a required reserved name, toss the message
128
* into the bit bucket, and issue a warning instead.
130
#define STREQ(x,y) (strcasecmp(x,y) == 0)
132
if (STREQ(state.msg_attr.local, MAIL_ADDR_MAIL_DAEMON)
133
|| STREQ(state.msg_attr.local, MAIL_ADDR_POSTMASTER)) {
134
msg_warn("required alias not found: %s", state.msg_attr.local);
135
return (sent(BOUNCE_FLAGS(state.request),
136
SENT_ATTR(state.msg_attr),
141
* Bounce the message when no luser relay is specified.
143
return (bounce_append(BOUNCE_FLAGS(state.request),
144
BOUNCE_ATTR(state.msg_attr),
145
"unknown user: \"%s\"", state.msg_attr.local));