]> Cypherpunks.ru repositories - nncp.git/blob - doc/integration/exim.texi
26472ea46291ce907881daa971eaa9fac558c088
[nncp.git] / doc / integration / exim.texi
1 @node Exim
2 @section Integration with Exim
3
4 This section is unaltered copy-paste of
5 @url{https://changelog.complete.org/archives/10165-asynchronous-email-exim-over-nncp-or-uucp, Asynchronous Email: Exim over NNCP (or UUCP)}
6 article by John Goerzen, with his permission.
7
8 @strong{Sending from Exim to a smarthost}
9
10 One common use for async email is from a satellite system: one that
11 doesn't receive mail, or have local mailboxes, but just needs to get
12 email out to the Internet. This is a common situation even for
13 conventionally-connected systems; in Exim speak, this is a "satellite
14 system that routes mail via a smarthost". That is, every outbound
15 message goes to a specific target, which then is responsible for
16 eventual delivery (over the Internet, LAN, whatever).
17
18 This is fairly simple in Exim.
19
20 We actually have two choices for how to do this: @command{bsmtp} or
21 @command{rmail} mode. bsmtp (batch SMTP) is the more modern way, and is
22 essentially a derivative of SMTP that explicitly can be queued
23 asynchronously. Basically it's a set of SMTP commands that can be saved
24 in a file. The alternative is @command{rmail} (which is just an alias
25 for sendmail these days), where the data is piped to
26 @command{rmail}/@command{sendmail} with the recipients given on the
27 command line. Both can work with Exim and NNCP, but because we're doing
28 shiny new things, we'll use @command{bsmtp}.
29
30 These instructions are loosely based on the
31 @url{https://people.debian.org/~jdg/bsmtp.html, Using outgoing BSMTP with Exim HOWTO}.
32 Some of these may assume Debianness in the configuration, but should be
33 easily enough extrapolated to other configs as well.
34
35 First, configure Exim to use satellite mode with minimal DNS lookups
36 (assuming that you may not have working DNS anyhow).
37
38 Then, in the Exim primary router section for smarthost
39 (@file{router/200_exim4-config_primary} in Debian split configurations),
40 just change @code{transport = remote_smtp_smarthost to transport = nncp}.
41
42 Now, define the NNCP transport. If you are on Debian, you might name this
43 @file{transports/40_exim4-config_local_nncp}:
44
45 @example
46 nncp:
47   debug_print = "T: nncp transport for $local_part@@$domain"
48   driver = pipe
49   user = nncp
50   batch_max = 100
51   use_bsmtp
52   command = /usr/local/nncp/bin/nncp-exec -noprogress -quiet hostname_goes_here rsmtp
53 .ifdef REMOTE_SMTP_HEADERS_REWRITE
54   headers_rewrite = REMOTE_SMTP_HEADERS_REWRITE
55 .endif
56 .ifdef REMOTE_SMTP_RETURN_PATH
57   return_path = REMOTE_SMTP_RETURN_PATH
58 .endif
59 @end example
60
61 This is pretty straightforward. We pipe to @command{nncp-exec}, run it
62 as the nncp user. @command{nncp-exec} sends it to a target node and runs
63 whatever that node has called @command{rsmtp} (the command to receive
64 bsmtp data). When the target node processes the request, it will run the
65 configured command and pipe the data in to it.
66
67 @strong{More complicated: Routing to various NNCP nodes}
68
69 Perhaps you would like to be able to send mail directly to various NNCP
70 nodes. There are a lot of ways to do that.
71
72 Fundamentally, you will need a setup similar to the UUCP example in
73 @url{https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_manualroute_router.html,
74 Exim's manualroute manual}, which lets you define how to reach various
75 hosts via UUCP/NNCP. Perhaps you have a star topology (every NNCP node
76 exchanges email with a central hub). In the NNCP world, you have two
77 choices of how you do this. You could, at the Exim level, make the
78 central hub the smarthost for all the side nodes, and let it
79 redistribute mail. That would work, but requires decrypting messages at
80 the hub to let Exim process. The other alternative is to configure NNCP
81 to just send to the destinations via the central hub; that takes
82 advantage of onion routing and doesn't require any Exim processing at
83 the central hub at all.
84
85 @strong{Receiving mail from NNCP}
86
87 On the receiving side, first you need to configure NNCP to authorize the
88 execution of a mail program. In the section of your receiving host where
89 you set the permissions for the client, include something like this:
90
91 @example
92 exec: @{
93     rsmtp: ["/usr/sbin/sendmail", "-bS"]
94 @}
95 @end example
96
97 The @option{-bS} option is what tells Exim to receive BSMTP on @code{stdin}.
98
99 Now, you need to tell Exim that nncp is a trusted user (able to set From
100 headers arbitrarily). Assuming you are running NNCP as the @code{nncp} user,
101 then add @code{MAIN_TRUSTED_USERS = nncp} to a file such as
102 @file{/etc/exim4/conf.d/main/01_exim4-config_local-nncp}. That's it!
103
104 Some hosts, of course, both send and receive mail via NNCP and will need
105 configurations for both.