]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/sendmail/cf/feature/bcc.m4
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / sendmail / cf / feature / bcc.m4
1 divert(-1)
2 #
3 # Copyright (c) 2014 Proofpoint, Inc. and its suppliers.
4 #       All rights reserved.
5 #
6 # By using this file, you agree to the terms and conditions set
7 # forth in the LICENSE file which can be found at the top level of
8 # the sendmail distribution.
9 #
10 #
11
12 divert(-1)
13 # Arguments:
14 # 1: Map to use
15 #   - empty/none: default map bcctable
16 #   - `access': to use access_db (with bcc: as tag)
17 #   - map definition
18 #   The map contains domain names and the RHS should be simply "ok".
19 #   If the access map is used, then its lookup algorithm is used.
20 #   Otherwise:
21 #    domain     ok
22 #   matches anything@domain
23 #    .domain    ok
24 #   matches any subdomain, e.g., l@sub.domain and l@sub.dom.domain
25 #   On a match, the original address will be used as bcc address unless
26 #   argument 3 is set.
27 # 2: Name of host ([mailer:]host)
28 # 3: Default bcc address: if set, this will be always used.
29 #   Only one of 2/3 can be empty.
30 #   Note: if Bcc address is used then only one copy will be sent!
31 #   (due to duplicate elimination)
32 # 4: Map definition for canonicalRcpt map of address rewriting to
33 #   apply to the added bcc envelope recipients.
34 #   The option -T<TMPF> is required to handle temporary map failures.
35 #
36 # The ruleset must return either
37 # - an e-mail address (user@dom.ain) which is then added as "bcc" recipient.
38 # - an empty string: do not add a "bcc" recipient, or
39 # - $#error: fail the SMTP transaction (e.g., temporary lookup failure)
40 #
41 # This feature sets O AddBcc=true
42
43 ifelse(lower(_ARG_),`access',`define(`_BCC_ACCESS_', `1')')
44 define(`_ADD_BCC_', `1')
45
46 ifdef(`_BCC_ACCESS_', `dnl
47 ifdef(`_ACCESS_TABLE_', `',
48         `errprint(`*** ERROR: FEATURE(`bcc') requires FEATURE(`access_db')
49 ')')')
50
51 ifdef(`_BCC_ACCESS_', `', `
52 LOCAL_CONFIG
53 Kbcctable ifelse(defn(`_ARG_'), `', DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`bcctable', `_ARG_')')
54
55 LOCAL_CONFIG
56 O AddBcc=true
57 ifelse(len(X`'_ARG2_),`1', `', `
58 DA`'_ARG2_')
59
60 ifelse(len(X`'_ARG4_), `1', `',
61 `define(`_CANONIFY_BCC_', `1')dnl
62 define(`_NEED_SMTPOPMODES_', `1')dnl
63 # canonical address look up for AddBcc recipients
64 KcanonicalRcpt _ARG4_
65 ')dnl
66
67 LOCAL_RULESETS
68 Sbcc
69 R< $+ >                 $1
70 ifdef(`_BCC_ACCESS_', `dnl
71 R$+ @ $+                $: $1@$2 $| $>SearchList <! bcc> $| <D:$2> <>',
72 `R$+ @ $+               $: $1@$2 $| $>BCC $2')
73 R$* $| <?>              $@
74 R$* $| $*               $: ifelse(len(X`'_ARG3_),`1', `$1', `_ARG3_')
75
76 ifdef(`_CANONIFY_BCC_', `dnl
77 R$+ @ $+                $: $1@$2 $| <$(canonicalRcpt $1 @ $2 $: $)>
78 R$* $| <>               $@
79 R$* $| <$* <TMPF>>      $#error $@ 4.3.0 $: "451 Temporary system failure. Please try again later."
80 R$* $| <$+>             $@ $2                   map matched?
81 ')
82
83
84 ifdef(`_BCC_ACCESS_', `', `
85 SBCC
86 R$+             $: $1 < $(bcctable $1 $: ? $) >
87 R$- . $+ <?>    $: $2 < $(bcctable .$2 $: ? $) >
88 R$- . $+ <?>    $: $>BCC $2
89 R$* <$*>        $: <$2>
90 ')