xref: /netbsd-src/external/ibm-public/postfix/dist/html/ETRN_README.html (revision 059c16a85b0b39d60ad6d18f53c09510815afa2b)
1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd">
3
4<html>
5
6<head>
7
8<title>Postfix ETRN Howto</title>
9
10<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
11<link rel='stylesheet' type='text/css' href='postfix-doc.css'>
12
13</head>
14
15<body>
16
17<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix ETRN Howto</h1>
18
19<hr>
20
21<h2>Purpose of the Postfix fast ETRN service</h2>
22
23<p> The SMTP ETRN command was designed for sites that have intermittent
24Internet connectivity. With ETRN, a site can tell the mail server
25of its provider to "Please deliver all my mail now". The SMTP server
26searches the queue for mail to the customer, and delivers that mail
27<b>by connecting to the customer's SMTP server</b>. The mail is
28not delivered via the connection that was used for sending ETRN.
29</p>
30
31<p> As of version 1.0, Postfix has a fast ETRN implementation that
32does not require Postfix to examine every queue file.  Instead,
33Postfix maintains a record of what queue files contain mail for
34destinations that are configured for ETRN service.  ETRN service
35is no longer available for domains that aren't configured for the
36service.  </p>
37
38<p> This document provides information on the following topics: </p>
39
40<ul>
41
42<li><a href="#using">Using the Postfix fast ETRN service</a>
43
44<li><a href="#how">How Postfix fast ETRN works</a>
45
46<li><a href="#dirty_secret">Postfix fast ETRN service limitations</a>
47
48<li><a href="#config">Configuring the Postfix fast ETRN service</a>
49
50<li><a href="#only">Configuring a domain for ETRN service only</a>
51
52<li><a href="#testing">Testing the Postfix fast ETRN service</a>
53
54</ul>
55
56<p> Other documents with information on this subject: </p>
57
58<ul>
59
60<li> <a href="flush.8.html">flush(8)</a>, flush service implementation
61
62</ul>
63
64<h2><a name="using">Using the Postfix fast ETRN service</a> </h2>
65
66<p> The following is an example SMTP session that shows how an SMTP
67client requests the ETRN service. Client commands are shown in bold
68font.  </p>
69
70<blockquote>
71<pre>
72220 my.server.tld ESMTP Postfix
73<b>HELO my.client.tld</b>
74250 Ok
75<b>ETRN some.customer.domain</b>
76250 Queuing started
77<b>QUIT</b>
78221 Bye
79</pre>
80</blockquote>
81
82<p> As mentioned in the introduction, the mail is delivered by
83connecting to the customer's SMTP server; it is not sent over
84the connection that was used to send the ETRN command. </p>
85
86<p> The Postfix operator can request delivery for a specific customer
87by using the command "sendmail -qR<i>destination</i>" and, with
88Postfix version 1.1 and later, "postqueue -s<i>destination</i>".
89Access to this feature is controlled with the <a href="postconf.5.html#authorized_flush_users">authorized_flush_users</a>
90configuration parameter (Postfix version 2.2 and later).
91</p>
92
93<h2><a name="how">How Postfix fast ETRN works</a></h2>
94
95<p> When a Postfix delivery agent decides that mail must be delivered
96later, it sends the destination domain name and the queue file name
97to the <a href="flush.8.html">flush(8)</a> daemon which maintains per-destination logfiles
98with file names of queued mail.  These logfiles are kept below
99$<a href="postconf.5.html#queue_directory">queue_directory</a>/flush. Per-destination logfiles are maintained
100only for destinations that are listed with the $<a href="postconf.5.html#fast_flush_domains">fast_flush_domains</a>
101parameter and that have syntactically valid domain names.  </p>
102
103<blockquote>
104
105<table>
106
107<tr>
108
109<td bgcolor="#f0f0ff" align="center" valign="middle"> Postfix<br>
110delivery<br> agent</td>
111
112<td> <tt>-</tt>(domain, queue ID)<tt>-&gt;</tt> </td>
113
114<td bgcolor="#f0f0ff" align="center" valign="middle"> Postfix<br>
115flush<br> daemon</td>
116
117<td> <tt>-</tt>(queue ID)<tt>-&gt;</tt> </td>
118
119<td bgcolor="#f0f0ff" align="center" valign="middle"> One logfile <br>
120per eligible<br> domain </td>
121
122</tr>
123
124</table>
125
126</blockquote>
127
128<p> When Postfix receives a request to "deliver mail for a domain
129now", the <a href="flush.8.html">flush(8)</a> daemon moves all <a href="QSHAPE_README.html#deferred_queue">deferred queue</a> files that are
130listed for that domain to the <a href="QSHAPE_README.html#incoming_queue">incoming queue</a>, and requests that
131the queue manager deliver them. In order to force delivery, the
132queue manager temporarily ignores the lists of undeliverable
133destinations:  the volatile in-memory list of dead domains, and
134the list of message delivery transports specified with the
135<a href="postconf.5.html#defer_transports">defer_transports</a> configuration parameter. </p>
136
137<h2><a name="dirty_secret">Postfix fast ETRN service limitations</a></h2>
138
139<p> The design of the <a href="flush.8.html">flush(8)</a> server and of the flush queue
140introduce a few limitations that should not be an issue unless you
141want to turn on fast ETRN service for every possible destination.
142</p>
143
144<ul>
145
146<li> <p> The <a href="flush.8.html">flush(8)</a> daemon maintains per-destination logfiles
147with queue file names. When a request to "deliver mail now" arrives,
148Postfix will attempt to deliver all recipients in the queue files
149that have mail for the destination in question.  This does not
150perform well with queue files that have recipients in many different
151domains, such as queue files with outbound mailing list traffic.
152</p>
153
154<li> <p> The <a href="flush.8.html">flush(8)</a> daemon maintains per-destination logfiles
155only for destinations listed with $<a href="postconf.5.html#fast_flush_domains">fast_flush_domains</a>. With other
156destinations you cannot request delivery with "sendmail
157-qR<i>destination</i>" or, with Postfix version 1.1 and later,
158"postqueue -s<i>destination</i>". </p>
159
160<li> <p> Up to and including early versions of Postfix version 2.1,
161the "fast flush" service may not deliver some messages if the
162request to "deliver mail now" is received while a <a href="QSHAPE_README.html#deferred_queue">deferred queue</a>
163scan is already in progress. The reason is that the queue manager
164does not ignore the volatile in-memory list of dead domains, and
165the list of message delivery transports specified with the
166<a href="postconf.5.html#defer_transports">defer_transports</a> configuration parameter.  </p>
167
168<li> <p> Up to and including Postfix version 2.3, the "fast flush"
169service may not deliver some messages if the request to "deliver
170mail now" arrives while an <a href="QSHAPE_README.html#incoming_queue">incoming queue</a> scan is already in progress.
171</p>
172
173</ul>
174
175<h2><a name="config">Configuring the Postfix fast ETRN service</a></h2>
176
177<p> The behavior of the <a href="flush.8.html">flush(8)</a> daemon is controlled by parameters
178in the <a href="postconf.5.html">main.cf</a> configuration file. </p>
179
180<p> By default, Postfix "fast ETRN" service is available only for
181destinations that Postfix is willing to relay mail to:  </p>
182
183<blockquote>
184<pre>
185/etc/postfix/<a href="postconf.5.html">main.cf</a>:
186    <a href="postconf.5.html#fast_flush_domains">fast_flush_domains</a> = $<a href="postconf.5.html#relay_domains">relay_domains</a>
187    <a href="postconf.5.html#smtpd_etrn_restrictions">smtpd_etrn_restrictions</a> = <a href="postconf.5.html#permit_mynetworks">permit_mynetworks</a>, reject
188</pre>
189</blockquote>
190
191<p> Notes: </p>
192
193<ul>
194
195<li> <p> The <a href="postconf.5.html#relay_domains">relay_domains</a> parameter specifies what destinations
196Postfix will relay to.  For destinations that are not eligible for
197the "fast ETRN" service, Postfix replies with an error message.
198</p>
199
200<li> <p> The <a href="postconf.5.html#smtpd_etrn_restrictions">smtpd_etrn_restrictions</a> parameter limits what clients
201may execute the ETRN command. By default, any client has permission.
202</p>
203
204</ul>
205
206<p> To enable "fast ETRN" for some other destination, specify: </p>
207
208<blockquote>
209<pre>
210/etc/postfix/<a href="postconf.5.html">main.cf</a>:
211    <a href="postconf.5.html#fast_flush_domains">fast_flush_domains</a> = $<a href="postconf.5.html#relay_domains">relay_domains</a>, some.other.domain
212</pre>
213</blockquote>
214
215<p> To disable "fast ETRN", so that Postfix rejects all ETRN requests
216and so that it maintains no per-destination logfiles, specify: </p>
217
218<blockquote>
219<pre>
220/etc/postfix/<a href="postconf.5.html">main.cf</a>:
221    <a href="postconf.5.html#fast_flush_domains">fast_flush_domains</a> =
222</pre>
223</blockquote>
224
225<h2><a name="only">Configuring a domain for ETRN service only</a></h2>
226
227<p> While an "ETRN" customer is off-line, Postfix will make
228spontaneous attempts to deliver mail to it. These attempts are
229separated in time by increasing time intervals, ranging from
230$<a href="postconf.5.html#minimal_backoff_time">minimal_backoff_time</a> to $<a href="postconf.5.html#maximal_backoff_time">maximal_backoff_time</a>, and should not be
231a problem unless a lot of mail is queued. </p>
232
233<p> To prevent Postfix from making spontaneous delivery attempts
234you can configure Postfix to always defer mail for the "ETRN"
235customer.  Mail is delivered only after the ETRN command or with
236"sendmail -q", with "sendmail -qR<i>domain</i>", or with "postqueue
237-s<i>domain</i>"(Postfix version 1.1 and later only), </p>
238
239<p> In the example below we configure an "etrn-only" delivery
240transport which is simply a duplicate of the "smtp" and "relay"
241mail delivery transports. The only difference is that mail destined
242for this delivery transport is deferred as soon as it arrives.
243</p>
244
245<blockquote>
246<pre>
247 1 /etc/postfix/<a href="master.5.html">master.cf</a>:
248 2   # =============================================================
249 3   # service type  private unpriv  chroot  wakeup  maxproc command
250 4   #               (yes)   (yes)   (yes)   (never) (100)
251 5   # =============================================================
252 6   smtp      unix  -       -       n       -       -       smtp
253 7   relay     unix  -       -       n       -       -       smtp
254 8   etrn-only unix  -       -       n       -       -       smtp
255 9
25610 /etc/postfix/<a href="postconf.5.html">main.cf</a>:
25711   <a href="postconf.5.html#relay_domains">relay_domains</a> = customer.tld ...other domains...
25812   <a href="postconf.5.html#defer_transports">defer_transports</a> = etrn-only
25913   <a href="postconf.5.html#transport_maps">transport_maps</a> = <a href="DATABASE_README.html#types">hash</a>:/etc/postfix/transport
26014
26115 /etc/postfix/transport:
26216   customer.tld     etrn-only:[mailhost.customer.tld]
263</pre>
264</blockquote>
265
266<p>Translation: </p>
267
268<ul>
269
270<li> <p> Line 8: The "etrn-only" mail delivery service is a copy of the
271"smtp" and "relay" service. </p>
272
273<li> <p> Line 11: Don't forget to authorize relaying for this
274customer, either via <a href="postconf.5.html#relay_domains">relay_domains</a> or with the <a href="postconf.5.html#permit_mx_backup">permit_mx_backup</a>
275feature. </p>
276
277<li> <p> Line 12: The "etrn-only" mail delivery service is configured
278so that spontaneous mail delivery is disabled. </p>
279
280<li> <p> Lines 13-16: Mail for the customer is given to the
281"etrn-only" mail delivery service. </p>
282
283<li> <p> Line 16: The "[mailhost.customer.tld]" turns off MX record
284lookups; you must specify this if your Postfix server is the primary
285MX host for the customer's domain.  </p>
286
287</ul>
288
289<h2><a name="testing">Testing the Postfix fast ETRN service</a></h2>
290
291<p> By default, "fast ETRN" service is enabled for all domains that
292match $<a href="postconf.5.html#relay_domains">relay_domains</a>.  If you run Postfix with "fast ETRN" service
293for the very first time, you need to run "sendmail -q" once
294in order to populate the per-site deferred mail logfiles.  If you
295omit this step, no harm is done.  The logfiles will eventually
296become populated as Postfix routinely attempts to deliver delayed
297mail, but that will take a couple hours.  After the "sendmail
298-q" command has completed all delivery attempts (this can take
299a while), you're ready to test the "fast ETRN" service.
300
301<p> To test the "fast ETRN" service, telnet to the Postfix SMTP
302server from a client that is allowed to execute ETRN commands (by
303default, that's every client), and type the commands shown in
304boldface: </p>
305
306<blockquote>
307<pre>
308220 my.server.tld ESMTP Postfix
309<b>HELO my.client.tld</b>
310250 Ok
311<b>ETRN some.customer.domain</b>
312250 Queuing started
313</pre>
314</blockquote>
315
316<p> where "some.customer.domain" is the name of a domain that has
317a non-empty logfile somewhere under $<a href="postconf.5.html#queue_directory">queue_directory</a>/flush. </p>
318
319<p> In the maillog file, you should immediately see a couple of
320logfile records, as evidence that the queue manager has opened
321queue files: </p>
322
323<blockquote>
324<pre>
325Oct  2 10:51:19 <a href="postconf.5.html#myhostname">myhostname</a> postfix/qmgr[51999]: 682E8440A4:
326    from=&lt;whatever&gt;, size=12345, nrcpt=1 (queue active)
327Oct  2 10:51:19 <a href="postconf.5.html#myhostname">myhostname</a> postfix/qmgr[51999]: 02249440B7:
328    from=&lt;whatever&gt;, size=4711, nrcpt=1 (queue active)
329</pre>
330</blockquote>
331
332<p> What happens next depends on whether the destination is reachable.
333If it's not reachable, the mail queue IDs will be added back to
334the some.customer.domain logfile under $<a href="postconf.5.html#queue_directory">queue_directory</a>/flush.
335</p>
336
337<p> Repeat the exercise with some other destination that your server
338is willing to relay to (any domain listed in $<a href="postconf.5.html#relay_domains">relay_domains</a>), but
339that has no mail queued. The text in bold face stands for the
340commands that you type: </p>
341
342<blockquote>
343<pre>
344220 my.server.tld ESMTP Postfix
345<b>HELO my.client.tld</b>
346250 Ok
347<b>ETRN some.other.customer.domain</b>
348250 Queuing started
349</pre>
350</blockquote>
351
352<p> This time, the "ETRN"" command should trigger NO mail deliveries
353at all. If this triggers delivery of all mail, then you used the
354wrong domain name, or "fast ETRN" service is turned off.  </p>
355
356<p> Finally, repeat the exercise with a destination that your mail
357server is not willing to relay to.  It does not matter if your
358server has mail queued for that destination. </p>
359
360<blockquote>
361<pre>
362220 my.server.tld ESMTP Postfix
363<b>HELO my.client.tld</b>
364250 Ok
365<b>ETRN not.a.customer.domain</b>
366459 &lt;not.a.customer.domain&gt;: service unavailable
367</pre>
368</blockquote>
369
370<p> In this case, Postfix should reject the request
371as shown above. </p>
372
373</body>
374
375</html>
376