aboutsummaryrefslogtreecommitdiff
path: root/doc/calloutd.texi
blob: 0dfef7b0fa68d0593c6721125ada2dbf6fad8b8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
@c This file is part of the Mailfromd manual.
@c Copyright (C) 2011-2019 Sergey Poznyakoff
@c See file mailfromd.texi for copying conditions.
@c *******************************************************************
@pindex calloutd
  The callout verification is usually performed by a special instance of
@command{mailfromd} (@pxref{callout server}).  However, it is also
possible to set up a dedicated callout server on a separate machine.
You can choose to do so, for instance, in order to reduce the load on
the server running @command{mailfromd}.

  This stand-alone callout facility is provided by the
@command{calloutd} daemon.

@menu
* config-calloutd::     Calloutd Configuration.
* invocation-calloutd:: Calloutd Command-Line Options.
* protocol-calloutd::   The Callout Protocol.
@end menu

@node config-calloutd
@section Calloutd Configuration
Main configuration file @file{/etc/mailfromd.conf} is used
(@pxref{Mailfromd Configuration}).  The configuration statements are
basically the same as for @command{mailfromd}.

The address to listen on is defined in the @code{server} statement.
Basically, it is the only statement the configuration file is required
to have.  The minimal configuration can look like:

@example
program calloutd @{
  server @{
    listen inet://198.51.100.1:3535;
  @}
@}  
@end example

To instruct the @command{mailfromd} daemon to use this server, the
following statement should be added to the @file{/etc/mailfromd.conf}
file:

@example
program mailfromd @{
  callout-url inet://198.51.100.1:3535;
@}  
@end example

The @code{server} statement differs a little from the similar
statement for @command{mailfromd}.  This and another
@command{calloutd}-specific statements are described in detail in the
subsections that follow.  The rest of statements is shared with
@command{mailfromd}.  The following table lists all supported
configuration statements along with cross-references to the
correspondent descriptions:

@multitable @columnfractions 0.3 0.6
@headitem Statement @tab Reference
@item @code{acl} @tab @xref{acl statement,Mailutils Configuration File,,
mailutils, GNU Mailutils Manual}.
@item @code{auth} @tab @xref{auth statement, Mailutils Configuration File,,
mailutils, GNU Mailutils Manual}.
@item @code{database} @tab @xref{conf-database}.
@item @code{database-mode} @tab @xref{conf-database,database-mode}.
@item @code{database-type} @tab @xref{conf-database,database-type}.
@item @code{debug} (section) @tab @xref{debug statement, Mailutils Configuration File,,
mailutils, GNU Mailutils Manual}.
@item @code{debug} @tab @xref{conf-calloutd-log}.
@item @code{ehlo-domain} @tab @xref{conf-callout, ehlo-domain}.
@item @code{enable-vrfy} @tab @xref{conf-callout, enable-vrfy}.
@item @code{group} @tab @xref{conf-priv, group}.
@item @code{include} @tab @xref{include, Mailutils Configuration File,,mailutils, GNU Mailutils Manual}.
@item @code{io-timeout} @tab @xref{conf-timeout, io-timeout}.
@item @code{locking} @tab @xref{locking statement, Mailutils Configuration File,,
mailutils, GNU Mailutils Manual}.
@item @code{lock-retry-count} @tab @xref{conf-database, lock-retry-count}.
@item @code{lock-retry-timeout} @tab @xref{conf-database, lock-retry-timeout}.
@item @code{logger} @tab @xref{conf-calloutd-log}.
@item @code{logging} @tab @xref{logging statement, Mailutils Configuration File,,
mailutils, GNU Mailutils Manual}.
@item @code{mailer} @tab @xref{mailer statement, Mailutils Configuration File,,
mailutils, GNU Mailutils Manual}.
@item @code{mail-from-address} @tab @xref{conf-callout, mail-from-address}.
@item @code{pidfile} @tab @xref{conf-calloutd-setup, pidfile}.
@item @code{server} @tab @xref{conf-calloutd-server}.
@item @code{source-ip} @tab @xref{conf-calloutd-setup, source-ip}.
@item @code{smtp-timeout} @tab @xref{conf-timeout}.
@item @code{state-directory} @tab @xref{conf-calloutd-setup, state-directory}.
@item @code{transcript} @tab @xref{conf-calloutd-log},
@item @code{user} @tab @xref{conf-priv, user}.
@end multitable

@menu
* conf-calloutd-setup:: @command{calloutd} General Setup.
* conf-calloutd-server:: The @code{server} Statement.
* conf-calloutd-log:: @command{calloutd} Logging.
@end menu

@node conf-calloutd-setup
@subsection @command{calloutd} General Setup

@deffn {Calloutd Conf} source-ip IP
Sets source IP address for TCP connections.
@end deffn

@deffn {Calloutd Conf} pidfile filename
Defines the name of the file to store PID value in.
@end deffn

@deffn {Calloutd Conf} state-directory dir
Sets the name of the program state directory.  @xref{statedir}.
@end deffn

@node conf-calloutd-server
@subsection The @code{server} statement

The @code{server} statement configures how @command{calloutd} will
communicate with the client @command{mailfromd} server.

@smallexample
@group
server @{
  id @var{name};
  listen @var{url};
  backlog @var{num};
  max-instances @var{num};
  single-process @var{bool};
  reuseaddr @var{bool};
  default @var{bool};
  callout @var{url};
  acl @{ @dots{} @}
@}
@end group
@end smallexample

@deffn {Calloutd Conf} server
  Define a server.  Optional label may follow the @code{server}
  keyword.  The label is ignored.
  
  The substatements in the @code{server} block provide parameters for
configuring this server.  
@end deffn

@deffn {server} id name
  Assign an identifier to this server.  This identifier is used as
a suffix to syslog tag (@pxref{syslog tag}) in messages related to
this server.  For example, if a server block had the following
statement in it:

@smallexample
id main;
@end smallexample

@noindent
then all messages related to this server will be marked with tag
@samp{calloutd#main}.

  The part before the @samp{#} is set using the @code{tag} statement
in @code{logging} block (@pxref{Logging Statement, Mailutils
Configuration File,, mailutils, GNU Mailutils Manual}).
@end deffn

@deffn {server} listen url
Listen for connections on the given @acronym{URL}.
@xref{milter port specification}, for a description of allowed
@var{url} formats.

Example:

@smallexample
listen inet://10.10.10.1:3331;
@end smallexample
@end deffn

@deffn {server} backlog @var{num}
Configures the size of the queue of pending connections.  Default
value is 8.
@end deffn

@deffn {server} max-instances number
Sets the maximum number of instances allowed for this server.
@end deffn

@deffn {server} single-process bool
When set to @samp{yes}, this server will run in @dfn{single-process}
mode, i.e. it will not fork sub-processes to serve requests.  This
option is meant exclusively to assist in debugging
@command{calloutd}.  Don't use it for anything else but for
debugging! 
@end deffn

@deffn {server} reuseaddr bool
When set to @samp{yes}, @command{calloutd} will attempt to reuse
existing socket addresses.  This is the default behavior.
@end deffn

@deffn {server} acl { @var{statements} }
Defines access control list for this server.  @xref{ACL Statement, Mailutils
Configuration File,, mailutils, GNU Mailutils Manual}, for a detailed
discussion.

If the global ACL is defined as well, an incoming connection is
checked against both lists: first the per-server ACL, then the global
one.  The connection will be permitted only if it passes both checks.
@end deffn

@ignore
The following two statements are ignored:

option
default
@end ignore

@node conf-calloutd-log
@subsection @command{calloutd} logging

@deffn {Calloutd Conf} logger mech
Set default logger mechanism.  Allowed values for
@var{mech} are:

@table @asis
@item stderr
Log everything to the standard error.

@item syslog
Log to syslog.

@item syslog:async
Log to syslog using the asynchronous syslog implementation.
@end table

@xref{Logging and Debugging}, for a detailed discussion.
See also @ref{syslog-async, Using non-blocking syslog}, for
information on how to set default syslog implementation at compile time.
@end deffn

@deffn {Calloutd Conf} debug spec
  Set @command{mailfromd} debug verbosity level.  The @var{spec}
must be a valid debugging level specification (@pxref{debugging level specification}).
@end deffn

@deffn {Calloutd Conf} transcript @var{bool}
If the boolean value @var{bool} is @samp{true}, enables the transcript
of call-out SMTP sessions.
@end deffn

@node invocation-calloutd
@section Calloutd Command-Line Options

The @command{calloutd} invocation syntax is:

@example
  calloutd [@var{option}...]
@end example

The following options are available:

@subheading Server configuration modifiers
@table @option
@opsummary{foreground, calloutd}
@item --foreground
Stay in foreground.  When given this option, @command{calloutd} will
not disconnect itself from the controlling terminal and will run in
the foreground.

@opsummary{group, calloutd}
@item -g @var{name}
@itemx --group=@var{name}

Retain the group @var{name} when switching to user
privileges.  @xref{Starting and Stopping}.

@opsummary{pidfile, calloutd}
@item --pidfile=@var{file}
Set pidfile name.  Overrides the @code{pidfile} configuration
statement, which you are advised to use instead (@pxref{conf-base, pidfile}).

@opsummary{resolv-conf-file, calloutd}
@item --resolv-conf-file=@var{file}
Read resolver settings from @var{file}, instead of the default
@file{/etc/resolv.conf}.

@opsummary{source-ip, calloutd}
@item -S @var{ip}
@itemx --source-ip=@var{ip}
Set source address for @acronym{TCP} connections.  Overrides the
@samp{source-ip} configuration statement, which you are advised to use
instead (@pxref{conf-base, source-ip}). 

@opsummary{single-process, calloutd}
@item --single-process
Do not fork sub-processes to serve requests.  This option is meant to
assist in debugging @command{calloutd}.  Don't use it for anything
else but for debugging, as it terribly degrades performance!

@opsummary{state-directory, calloutd}
@item --state-directory=@var{dir}
Set new program state directory.  @xref{statedir, Local state directory}, for
the description of this directory and its purposes.

@opsummary{user, calloutd}
@item -u @var{name}
@itemx  --user @var{name}
Switch to this user's privileges after startup.  Overrides the @code{user}
configuration file statement, which you are advised to use instead
(@pxref{conf-priv, user}).  Default user is
@samp{@value{DEFAULT_USER}}.
@end table

@subheading Logging and debugging options
@table @option
@opsummary{debug, calloutd}
@item -d @var{string}
@itemx --debug=@var{string}
Set debugging level.  @xref{Logging and Debugging}.

@opsummary{log-facility, calloutd}
@item --log-facility=@var{facility}
Output logs to syslog @var{facility}.

@opsummary{log-tag, calloutd}
@item --log-tag=@var{string}
Tag syslog entries with the given @var{string}, instead of the program name.

@opsummary{logger, calloutd}
@item --logger=@var{mech}
Set logger mechanism (@var{mech} is one of @samp{stderr},
@samp{syslog}, @samp{syslog:async}).  @xref{Logging and Debugging}.

@opsummary{syslog, calloutd}
@item --syslog
Selects default syslog mechanism for diagnostic output.

@opsummary{stderr, calloutd}
@item --stderr
Directs all logging to standard output.  Similar to @option{--logger=stderr}.

@opsummary{source-ip, calloutd}
@item -S @var{ip}
@itemx --source-ip=@var{ip}
Set source address for @acronym{TCP} connections.  Overrides the
@samp{source-ip} configuration statement, which you are advised to use
instead (@pxref{conf-base, source-ip}). 

@opsummary{debug-level, calloutd}
@item --debug-level=@var{level}
Set Mailutils debugging level.  See
@uref{http://mailutils.org/wiki/Debug_level}, for a detailed
discussion of @var{level} argument.

@opsummary{source-info, calloutd}
@item --source-info
@itemx --no-source-info
Include @sc{c} source information in debugging messages.  This is
similar to setting @code{line-info yes} in the @code{debug}
configuration block (@pxref{debug statement, line-info,,
mailutils, GNU Mailutils Manual}).

The @option{--no-source-info} can be used to cancel the effect of the
@code{line-info yes} configuration statement.

You do not need this option, unless you are developing or debugging
@command{calloutd}.

@opsummary{transcript, calloutd}
@item -X
@itemx --transcript
@itemx --no-transcript
Enable or disable transcript of the @acronym{SMTP} sessions to the log
channel.  @xref{Logging and Debugging}.
@end table

@subheading Configuration file control
@table @option
@opsummary{config-file, calloutd}
@item --config-file=@var{file}
Load this configuration file.

@opsummary{config-lint, calloutd}
@item --config-lint
Check syntax of configuration files and exit.  Exit code is 0 if the
file or files are OK, and 78 otherwise.

@opsummary{config-verbose, calloutd}
@item --config-verbose
Verbosely log parsing of the configuration files.

@opsummary{no-site-config, calloutd}
@item --no-site-config
@itemx --no-config
Don't load site-wide configuration file.

@opsummary{set, calloutd}
@item --set=@var{param}=@var{value}
Set configuration parameter
@end table

@subheading Informational options
@table @option
@opsummary{config-help, calloutd}
@item --config-help
Show configuration file summary.

@opsummary{show-config-options, calloutd}
@item --show-config-options
Show compilation options.

@opsummary{help, calloutd}
@item -?
@itemx --help
Give a short  help list.

@opsummary{usage, calloutd}
@item --usage
Give a short usage message.

@opsummary{version, calloutd}
@item -V
@itemx --version
Print program version
@end table

@node protocol-calloutd
@section The Callout Protocol

This section describes the protocol used to communicate with the
@command{calloutd} server.

The protocol works over stream-oriented TCP/IP transport.  Either UNIX
or IPv4 socket can be used.  Commands and responses are terminated by
a single CR LF pair.  Each command occupies exactly one line.  If the
server succeeded in executing the command, it replies with a line
starting with the word @samp{OK}.  Depending on the command, this
keyword may be followed by a single space character and additional
information.  More information can be returned in @dfn{unsolicited
replies} before the @samp{OK} line.  Each unsolicited reply line
starts with and asterisk followed by a single horizontal space
character.

On error, the server replies with @samp{NO} followed by a horizontal
space character and human-readable description of the problem.

The valid commands are discussed below.  In examples illustrating the
commands, the lines sent by the client are prefixed with @kbd{C:}, and
lines sent by the server are prefixed with @kbd{S:}.

@deffn Command vrfy @var{email} [@var{option} @var{arg}]
Adds @var{email} to the queue of email addresses to be verified.
Available @var{option}s are:

@table @option
@item mode @var{kw}
Sets verification mode for this email address.  Available modes are:

@table @asis
@item mxfirst
@itemx default
The default mode.

If the @code{host} option is also given, its argument is taken as
the domain name.  Otherwise, domain part of @var{email} is used. 

The verification goes as follows.  First, determine MX servers for
that domain.  Query each of them in order of increasing priority.
First of them that replies determines the result of the test.

If no MX servers are defined for that domain, look for its @samp{A}
record.  If available, run SMTP probe on that IP.  

@item mxonly
Query MX servers for the domain specified with the @code{host} option.

@item hostonly
Query the server whose name or IP address is supplied with the
@code{host} option. 

@item hostfirst
The reverse of @code{mxfirst}: first query the host, then the MX
servers.  The domain must be specified using the @code{host} option.
@end table

@item host @var{name}
Supplies the domain name for @code{mxonly} and mode, and host name or
IP address for @code{hostfirst} and @code{hostonly} modes.  The use of 
this keyword with any of these modes is mandatory.

@item ehlo @var{string}
Use @var{string} as the argument to the SMTP @code{EHLO} command.

@item mailfrom @var{email}
Use @var{email} in the SMTP @code{MAIL FROM} command.
@end table

On success, the server replies with @samp{OK}, followed by a non-negative
session ID for that email:

@example
@kbd{C:} VRFY gray@@example.org
@kbd{S:} OK 0000000001
@end example
@end deffn

@deffn Command get @var{arg} [@var{arg}]
Query value of internal callout parameters.  Valid values for
@var{arg} are:

@table @asis
@item ehlo
Return the string used as argument to the SMTP @code{EHLO} command.

@item mailfromd
Return the email address that is used in the SMTP @code{MAIL FROM} command.
@end table

On success, the server returns the requested value (if found) in an
unsolicited reply:

@example
@kbd{C:} GET ehlo timeout
@kbd{S:} * ehlo=example.net
@kbd{S:} OK
@end example
@end deffn

@deffn Command sid @var{string}
Sets @var{string} as session identifier for that session.  Example:

@example
@kbd{C:} SID deadbeef
@kbd{S:} OK
@end example
@end deffn

@deffn Command timeout @var{connect} @var{initial} @var{helo} @
 @var{mail} @var{rcpt} @var{rset} @var{quit}
Sets timeouts for various stages of SMTP session.  On success,
@samp{OK} is returned.

@example
@kbd{C:} timeout 300 300 300 600 300 300 120
@kbd{S:} OK timeouts set
@end example
@end deffn

@deffn Command run
Runs callout session for emails registered with the @code{vrfy}
command.  On success, results of the check are returned after the
@samp{OK} keyword in a whitespace-separated list of
@samp{@var{id}=@var{result}} pairs.  In each pair, @var{id} is its
identifier as returned in the reply to the @code{VRFY} command and
@var{result} is one of the following result strings: @samp{success},
@samp{not_found}, @samp{failure}, @samp{temp_failure}, @samp{timeout}.

Additional information about each callout session is returned in
unsolicited replies.  Each such reply is prefixed with the email
identifier and callout stage name.  Stage names are:

@table @code
@item INIT @var{remote_name}
The @command{calloutd} server is establishing communication with the
remote SMTP server @var{remote_name}.

@item GRTNG @var{line}
@command{calloutd} received initial response from the remote server.
@var{line} is the first line of the reply.

@item HELO @var{line}
@command{calloutd} received response to the @code{EHLO} (or
@code{HELO}) command.  In case of multiline response, @var{line} is
the first line.

@item SENT @var{command}
The SMTP command @var{command} has been sent to the remote server.

@item RECV @var{line}
The remote server returned @var{line} in response.  In case of
multiline response, @var{line} is the first line.
@end table

Example of verification session:

@example
@group
@kbd{C:} RUN
@kbd{S:} * 0000000000 INIT mx.example.org
@kbd{S:} * 0000000000 GRTNG 220 mx.example.org ESMTP Ready
@kbd{S:} * 0000000000 HELO 250-mx.example.org Hello tester
@kbd{S:} * 0000000000 SENT RCPT TO:<gray@@example.org>
@kbd{S:} * 0000000000 RECV 250 Accepted
@kbd{S:} * 0000000001 INIT foo.example.net
@kbd{S:} * 0000000001 GRTNG 220 foo ESMTP server ready
@kbd{S:} * 0000000001 HELO 250-foo.example.net Hello
@kbd{S:} * 0000000001 SENT RCPT TO:<gray@@example.net>
@kbd{S:} * 0000000001 RECV 450 4.7.0 You are greylisted for 3600 seconds
OK 0000000000=success 0000000001=temp_failure
@end group
@end example
@end deffn

@deffn Command drop @var{serial}
Drop the email with the given @var{serial} number from the
verification queue.  Example:

@example
@kbd{C:} DROP 0000000002
@kbd{S:} OK
@end example
@end deffn

@deffn Command quit
Finishes the current session and disconnects from the callout server.

@example
@kbd{C:} QUIT
@kbd{S:} OK bye
@end example
@end deffn

Return to:

Send suggestions and report system problems to the System administrator.