1@c This is part of the GNU Mailutils manual.
2@c Copyright (C) 1999--2021 Free Software Foundation, Inc.
3@c See file mailutils.texi for copying conditions.
4@comment *******************************************************************
5@pindex mailutils
6The @command{mailutils} utility is a multi-purpose tool shipped with
7Mailutils.  It can be used for various mail and database-related
8tasks, as well as an auxiliary tool for compiling and linking programs
9with Mailutils.
10
11@menu
12* mailutils invocation syntax::
13* mailutils help::                Display a terse help summary.
14* mailutils info::                Show Mailutils configuration.
15* mailutils cflags::              Show compiler options.
16* mailutils ldflags::             List libraries required to link.
17* mailutils stat::                Show mailbox status.
18* mailutils query::               Query configuration values.
19* mailutils 2047::                Decode/encode email message headers.
20* mailutils filter::              Apply a chain of filters to the input.
21* mailutils acl::                 Test access control lists.
22* mailutils wicket::              Scan wickets for matching URLs.
23* mailutils dbm::                 DBM management tool.
24* mailutils logger::              Log data using Mailutils log facility.
25* mailutils pop::                 POP3 client shell.
26* mailutils imap::                IMAP4 client shell.
27* mailutils send::                Send a message.
28* mailutils smtp::                Run a SMTP session.
29* mailutils maildir_fixup::       Fix-up maildirs created by versions prior to 3.10.90
30@end menu
31
32@node mailutils invocation syntax
33@subsection Invocation Syntax
34@command{Mailutils} is a command line tool.  Its invocation syntax is:
35
36@example
37mailutils [@var{options}] @var{command} [@var{args}]
38@end example
39
40where @var{options} are options that affect the behavior of
41@command{mailutils} as a whole, @var{command} instructs it what it is to do
42and @var{args} are any arguments the @var{command} needs in order to be
43executed.
44
45The commands are:
46
47@table @asis
48@item 2047
49Decodes or encodes email message headers.
50@item acl
51Tests Mailutils access control lists.
52@item cflags
53Shows compiler options needed to compile with Mailutils.
54@item dbm
55Invokes a DBM management tool.
56@item ;filter
57Applies a chain of filters to the input.
58@item help
59Displays a terse help summary.
60@item imap
61Invokes an IMAP4 client shell (in development).
62@item info
63Displays information about Mailutils compile-time configuration.
64@item ldflags
65Constructs a @command{ld}(1) command line for linking a program with Mailutils.
66@item logger
67Logs information using Mailutils log facility.
68@item pop
69Invokes a POP3 client shell.
70@item query
71Queries configuration values.
72@item wicket
73Scans wicket for matching URLs
74@end table
75
76@node mailutils help
77@subsection mailutils help
78The @command{mailutils help} command lists all available options and command
79names along with short descriptions of what each of them does.  It is
80similar to the @command{mailutils --help} option.
81
82A command name can be supplied as an argument to
83@command{help}, in which case it will display a help page for that
84particular command, e.g.:
85
86@example
87mailutils help ldflags
88@end example
89
90will output help for the @command{ldflags} command.  It is synonymous
91to the @option{--help} option used with that particular command, e.g.:
92@command{mailutils ldflags --help}.
93
94@node mailutils info
95@subsection mailutils info
96The @command{mailutils info} command displays information about Mailutils
97compile-time configuration.  In normal form its output lists a single
98configuration flag per line, e.g.:
99
100@example
101$ mailutils info
102VERSION=2.99.93
103SYSCONFDIR=/etc
104MAILSPOOLDIR=/var/mail/
105SCHEME=mbox
106LOG_FACILITY=mail
107IPV6
108USE_LIBPAM
109HAVE_LIBLTDL
110WITH_GDBM
111WITH_GNUTLS
112WITH_GSASL
113@end example
114
115A configuration flag can consist either of a single word, indicating
116that a particular capability has been enabled at compile time, or of a
117keyword/value pair delimited by an equal sign, which indicates a
118particular value used by default for that feature.  For example,
119@samp{IPV6} means that Mailutils was compiled with support for IPv6,
120whereas @samp{SYSCONFDIR=/etc} means that the default place for
121configuration files is in @file{/etc} directory.
122
123Such short output is convenient for using @command{mailutils info} in scripts
124to decide whether it is possible to use a given feature.  To assist
125human users, the @option{--verbose} (@option{-v}) option is provided.
126It prints a short description next to each flag:
127
128@example
129$ mailutils info --verbose
130VERSION=2.99.93           - Version of this package
131SYSCONFDIR=/etc           - System configuration directory
132MAILSPOOLDIR=/var/mail/   - Default mail spool directory
133SCHEME=mbox               - Default mailbox type
134LOG_FACILITY=mail         - Default syslog facility
135IPV6                      - IPv6 support
136USE_LIBPAM                - PAM support
137HAVE_LIBLTDL              - a portable `dlopen' wrapper library
138WITH_GDBM                 - GNU DBM
139WITH_GNUTLS               - TLS support using GNU TLS
140WITH_GSASL                - SASL support using GNU SASL
141@end example
142
143@node mailutils cflags
144@subsection mailutils cflags
145The @command{mailutils cflags} command shows compiler options needed to
146compile a C source with Mailutils.  It is intended for use in
147configuration scripts and Makefiles, e.g.:
148
149@example
150CFLAGS=-g -O2 `mailutils cflags`
151@end example
152
153@node mailutils ldflags
154@subsection mailutils ldflags
155The @command{mailutils ldflags} command is a counterpart of @command{cflags}
156which is used for linking.  It constructs a @command{ld} command line
157for linking a program with Mailutils.
158
159When used without arguments, it outputs @command{ld} arguments which
160would link only with the core Mailutils library @file{libmailutils}, e.g.:
161
162@example
163$ mailutils ldflags
164-L/usr/local/lib -lmailutils
165@end example
166
167This command accepts a number of keywords which allow to select a
168particular subset of Mailutils libraries to link with.  In particular,
169the argument @samp{all} instructs it to link in all available libraries:
170
171@example
172$ mailutils ldflags all
173-L/usr/local/lib -lmu_mbox -lmu_mh -lmu_maildir -lmu_imap -lmu_pop \
174-lmu_mailer -lmu_compat -lmailutils -lmu_auth -lgsasl -lgnutls -lgcrypt \
175-lldap -lgnuradius -lpam -ldl
176@end example
177
178Other available keywords are:
179
180@table @asis
181@item mbox
182Link in the UNIX mbox format support.
183@item mh
184Link in the MH format support.
185@item maildir
186Link in the Maildir format support.
187@item imap
188Link in the IMAP protocol support.
189@item pop
190Link in the POP protocol support.
191@item mailer
192Enable support for mailers.
193@item sieve
194Link in the support for Sieve mail filtering language.
195@item dbm
196Link in the support for DBM databases (libmu_dbm library).
197@item auth
198Link in the Mailutils authentication library.
199@item guile
200Provide Guile language bindings.
201@item python
202Provide Python language bindings.
203@end table
204
205@node mailutils stat
206@subsection mailutils stat
207The command @command{mailutils stat} shows status of a mailbox.  The
208name or URL of the mailbox to operate upon is supplied in the first
209argument.  If not given, the command will display status of the
210invoking user system mailbox.
211
212@example
213$ mailutils stat
214type: maildir
215path: /var/mail/smith
216URL: /var/mail/smith
217size: 3498
218messages: 24
219recent messages: 3
220first unseen: 20
221uidvalidity: 1338543026
222next uid: 87
223access: 2016-12-15 09:15:08 +0200
224@end example
225
226The output format is controlled by the @option{--format} (@option{-c})
227option.  Its argument is the desired format string, composed of
228ordinary characters, which are reporduced on standard output verbatim,
229backslash sequences, and format specifiers, beginning with @samp{%}.
230
231@dfn{Backslash sequences} are interpreted as in C.
232
233A @dfn{format specifier} consists of a leading @samp{%} followed by a
234letter.  Optional @samp{:} may occur between @samp{%} and the letter.
235Its presense instructs the program to print the description of the
236corresponding value before the value itself.
237
238The following format sequences are understood:
239
240@table @asis
241@item %f
242Name of the mailbox as supplied in the command line.  If
243@command{mailutils stat} was used without explicit mailbox argument,
244@samp{%f} is equivalent to @samp{%U}.
245@item %t
246Type of the mailbox (@samp{mbox}, @samp{maildir}, etc.).  The
247description string is @samp{type}.
248@item %p
249Path to the mailbox.  In case of remote mailboxes, it is the path
250part of the mailbox URL.  Description string: @samp{path}.
251@item %U
252URL of the mailbox.  Description string: @samp{URL}.
253@item %s
254Size of the mailbox in octets.  Description string: @samp{size}.
255@item %c
256Number of messages in the mailbox.  Description string:
257@samp{messages}.
258@item %r
259Number of recent (unread) messages in the mailbox.  Description string:
260@samp{recent messages}.
261@item %u
262Index of the first unseen message.  Description string: @samp{first unseen}.
263@item %v
264The UIDVALIDITY value.  Description string: @samp{uidvalidity}.
265@item %n
266The UID value which will be assigned to the new message to be
267incorporated into the mailbox.  Description string: @samp{next uid}.
268@item %a
269Access time of the mailbox, as a number of seconds since the epoch.
270@item %A
271Access time of the mailbox in human-readable format.
272@end table
273
274@node mailutils query
275@subsection mailutils query
276The @command{mailutils query} command queries values from Mailutils
277configuration files.  It takes one or more configuration paths
278(@pxref{Paths}) as its arguments.  On output, it displays the values
279it found, each value on a separate line.  If the requested value is a
280block statement it is displayed in full.  For example, if main
281configuration file contained:
282
283@example
284logging @{
285   syslog yes;
286   facility mail;
287@}
288@end example
289
290Then:
291
292@example
293$ mailutils query .logging.syslog
294syslog yes;
295$ mailutils query .logging.syslog .logging.facility
296syslog yes;
297facility mail;
298$ mailutils query .logging
299logging @{
300  syslog yes;
301  facility mail;
302@};
303@end example
304
305Several command line options allow to modify output format.  The
306@option{--value} option instructs the command to output only values:
307
308@example
309$ mailutils query --value .logging.syslog
310yes
311@end example
312
313The @option{--path} option instructs it to print full pathnames for
314each value:
315
316@example
317$ mailutils query --path .logging.syslog
318logging.syslog: yes
319@end example
320
321The @option{--program} option instructs @command{mailutils} to behave as if
322it was called under another program name.  For example, the following
323command:
324
325@example
326$ mailutils query --program=pop3d .server.transcript
327@end example
328
329will return the value of the @samp{.server.transcript} statement which
330the @command{pop3d} utility would see.
331
332By default, @command{mailutils query} operates on the main configuration
333file.  Another configuration file can be supplied using the
334@option{--file} (@option{-f}) option:
335
336@example
337$ mailutils query --file /usr/local/etc/file.conf .pidfile
338@end example
339
340@node mailutils 2047
341@subsection mailutils 2047
342The @command{mailutils 2047} command is a filter for decoding or encoding
343email message headers formatted in accordance with RFC 2047 (see
344@uref{http://www.faqs.org/rfcs/rfc2047.html}.  By default, it operates
345in encode mode and assumes the @samp{iso-8859-1} encoding.  If
346arguments are supplied in the command line, they are treated as the
347text to operate upon.  Otherwise the command acts as a UNIX filter,
348reading lines from the standard input and printing results on the
349standard output.
350
351For example:
352
353@example
354$ mailutils 2047 'Keld J@o{}rn Simonsen <keld@@dkuug.dk>'
355=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@@dkuug.dk>
356@end example
357
358The decode mode can be requested via the @option{--decode}
359(@option{-d}) option:
360
361@example
362$ mailutils 2047 --decode '=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= \
363 <keld@@dkuug.dk>'
364Keld J@o{}rn Simonsen <keld@@dkuug.dk>
365@end example
366
367The @option{--charset} (@option{-c}) option changes the default
368character set.  It is meaningful both in decode and in encode modes.
369In decode mode it instructs the utility to convert the output to the
370given character set.  In encode mode it indicates the encoding of the
371input data, which will be reflected in the resulting string:
372
373@example
374$ mailutils 2047 --charset=utf-8 'Keld J@o{}rn Simonsen <keld@@dkuug.dk>'
375=?utf-8?Q?Keld J=C3=B8rn Simonsen <keld@@dkuug.dk>?=
376@end example
377
378The @option{--encoding} (@option{-E}) option can be used in encode
379mode to change the output encoding.  Valid arguments for this option
380are: @samp{quoted-printable} (the default) or @samp{base64}.
381
382The @option{--newline} (@option{-n}) option prints an additional
383newline character after each line of output.
384
385@node mailutils filter
386@subsection mailutils filter
387The @command{mailutils filter} command applies a chain of filters to the
388input.  The filters to apply and their arguments are given
389in the command line.  The full invocation syntax is:
390
391@example
392 mailutils filter [@var{option}] @var{filter-chain}
393@end example
394
395The syntax for @var{filter-chain} in Backus-Naur form follows:
396
397@example
398<filter-chain> ::= <filter> | <filter-chain> "+" <filter>
399<filter> ::= <filter-spec> <@var{ARG}>*
400<filter-spec> ::= <@var{WORD}> | "~" <@var{WORD}>
401@end example
402
403@noindent
404where @var{<WORD>} stands for the filter name and @var{<ARG>}
405represents filter arguments.  To obtain a list of known filter names,
406run:
407
408@example
409mailutils filter --list
410@end example
411
412Filters are applied in the order of their appearance, from left to
413right and operate in encode mode.  The plus sign has the same meaning
414as pipe in shell.  The default mode can be changed using the
415@option{--decode} (@option{-d}) and @option{--encode} (@option{-e}) options.
416Whatever the default mode is, a @samp{~} character before filter
417name reverts the mode for that filter alone.
418
419For example, to encode the contents of file @file{file.txt} in Base64
420run:
421
422@example
423mailutils filter base64 < file.txt
424@end example
425
426To convert it to base64 and use CRLF as line delimiters, run:
427
428@example
429mailutils filter base64 + crlf < file.txt
430@end example
431
432The following command will decode the produced output:
433
434@example
435mailutils filter --decode crlf + base64
436@end example
437
438It can also be written as
439
440@example
441mailutils filter ~crlf + ~base64
442@end example
443
444The following example converts the input from ISO-8859-2 to UTF-8,
445quotes eventual @samp{From} occurring at the beginning of a line,
446encodes the result in Base64 and changes line delimiters to CRLF:
447
448@example
449mailutils filter iconv iso-8859-2 utf-8 + from + base64 + crlf
450@end example
451
452This final example removes UNIX-style comments from the input and
453joins continuation lines:
454
455@example
456mailutils filter --decode inline-comment -S '#' + linecon
457@end example
458
459Such invocation can be useful in shell scripts to facilitate
460configuration file processing.
461
462@node mailutils acl
463@subsection mailutils acl
464The @command{mailutils acl} command tests Mailutils Access Control Lists.  By
465default it reads ACL from the Mailutils configuration file section
466@samp{acl}.  The command takes a list of IP addresses as its
467arguments, applies the ACL to each of them in turn and prints the result.
468
469To select the ACL to test, two options are provided.  The
470@option{--file} (@option{-f}) option supplies the name of
471configuration file to read instead of the default one.  The
472@option{--path} (@option{-p} option supplies the pathname
473(@pxref{Paths}) of the ACL section to use instead of the default @samp{.acl}.  For example, to test ACL in section @samp{server 213.130.1.232} of file @file{/etc/pop3d.conf} use:
474
475@example
476mailutils acl --file=/etc/pop3d.conf \
477       --path=/server="213.130.1.232"/acl @var{address}
478@end example
479
480As an example of its use, consider file @file{test.conf} with the
481following contents:
482
483@example
484acl @{
485        deny from 10.10.10.1;
486        deny from 10.10.1.0/24;
487        log from any "Connect from $@{address@}";
488        allow from 10.0.0.0/8;
489        allow from 192.168.1.0/24;
490        deny from any;
491@}
492@end example
493
494Then, running @command{mailutils acl --file=test.conf 127.0.0.1} you will get:
495
496@example
497Testing 127.0.0.1:
498mailutils: Connect from 127.0.0.1
499127.0.0.1: deny
500@end example
501
502More examples:
503
504@example
505$ mailutils acl --file=test.conf 127.0.0.1 10.10.10.1 \
506         10.10.1.3 10.5.3.1 192.168.1.0 192.168.2.0
507Testing 127.0.0.1:
508mailutils: Connect from 127.0.0.1
509127.0.0.1: deny
510Testing 10.10.10.1:
51110.10.10.1: deny
512Testing 10.10.1.3:
51310.10.1.3: deny
514Testing 10.5.3.1:
515mailutils: Connect from 10.5.3.1
51610.5.3.1: accept
517Testing 192.168.1.0:
518mailutils: Connect from 192.168.1.0
519192.168.1.0: accept
520Testing 192.168.2.0:
521mailutils: Connect from 192.168.2.0
522192.168.2.0: accept
523@end example
524
525The @command{mailutils} option @option{--debug-level} will give you a deeper
526insight into the address matching algorithm:
527
528@example
529$ mailutils --debug-level=acl.trace9 acl --file test.conf 127.0.0.1
530Testing 127.0.0.1:
531mailutils: Checking sockaddr 127.0.0.1
532mailutils: 1:deny: Does 10.10.10.1/255.255.255.255 match 127.0.0.1? no;
533mailutils: 2:deny: Does 10.10.1.0/255.255.255.0 match 127.0.0.1? no;
534mailutils: 3:log: Does any match 127.0.0.1? yes;
535mailutils: Expanding "Connect from $@{address@}";
536mailutils: Expansion: "Connect from 127.0.0.1";.
537mailutils: Connect from 127.0.0.1
538mailutils: 4:accept: Does 10.0.0.0/255.0.0.0 match 127.0.0.1? no;
539mailutils: 5:accept: Does 192.168.0.0/255.255.0.0 match 127.0.0.1? no;
540mailutils: 6:deny: Does any match 127.0.0.1? yes;
541127.0.0.1: deny
542@end example
543
544@xref{Debugging Categories,acl}.
545
546@node mailutils wicket
547@subsection mailutils wicket
548The @command{mailutils wicket} command looks up matching URLs in the
549Mailutils ticket file (by default, @file{~/.mu-tickets}) and prints
550them.  The URLs to look for are supplied in the command line.
551
552Consider the following ticket file as an example:
553
554@example
555smtp://foo:bar@@*
556smtp://bar:baz@@gnu.org
557*://baz:qux@@*
558*://quux:bar@@gnu.org
559@end example
560
561Now, running @command{mailutils wicket smtp://bar@@gnu.org} will show:
562
563@example
564smtp://bar@@gnu.org: /home/@var{user}/.mailutils-tickets:2
565@end example
566
567@noindent
568(where @var{user} is your login name).  This means that this URL
569matches the line 2 in your @file{.mailutils-tickets} file.  The
570@command{wicket} command does not show the actual matching line to
571avoid revealing eventual security-sensitive information.  You can
572instruct it to do so using the @option{--verbose} (@option{-v})
573option:
574
575@example
576$ mailutils wicket -v smtp://bar@@gnu.org
577smtp://bar@@gnu.org: /home/@var{user}/.mu-tickets:2: smtp://bar:***@@gnu.org
578@end example
579
580As you see, even in that case the tool hides the actual password part
581by replacing it with three asterisks.  If you are working in a secure
582environment, you can tell @command{mu wicket} to show passwords as
583well, by supplying the @option{-v} option twice.
584
585A counterpart of @option{--verbose} is the @option{--quite}
586(@option{-q}) option, which instructs @command{wicket} to suppress any
587output, excepting error messages.  This can be used in scripts, which
588analyze the @command{mailutils wicket} exit code to alter the control flow.
589
590The @command{mailutils wicket} tool exits with code 0 if all URLs were
591matched and with code 1 if some of them were not matched in the ticket
592file.  If an error occurred, the code 2 is returned.
593
594@node mailutils dbm
595@subsection mailutils dbm
596The @command{mailutils dbm} tool manages DBM files using @file{libmu_dbm}
597The invocation syntax is:
598
599@example
600mailutils dbm @var{subcommand} [@var{options}] @var{file} [@var{keys}]
601@end example
602@noindent
603or
604@example
605mailutils dbm [@var{options}] @var{subcommand} @var{file} [@var{keys}]
606@end example
607
608@noindent
609where @var{subcommand} selects the operation mode, @var{options}
610modify the tool behavior and @var{file} specifies the DBM file to
611operate upon.  Some @var{command}s allow for optional @var{keys} to be
612specified.
613
614The @var{file} argument can be either a DBM file name or a Database URL.
615
616@menu
617* Create a Database::
618* Add Records to a Database::
619* Delete Records::
620* List the Database::
621* Dump the Database::
622* Dump Formats::
623* Dbm Exit Codes::
624@end menu
625
626@node Create a Database
627@subsubsection Create a Database
628The @option{create} subcommand and its synonym @option{load} instruct
629the tool to create a new database:
630
631@example
632mailutils dbm create file.db
633@end example
634
635If the argument file already exists, it will be truncated prior to
636adding new records to it.
637
638The data to populate the database with are read from the standard
639input.  The @command{mailutils dbm} command supports several formats for
640these data, which are discussed later.  In the simplest case (a so
641called @samp{format 0.0}) each input line must consist of two fields
642separated by any amount of whitespace.  The first field is treated as
643a key and the second one as the corresponding value.
644
645The usual way to read data from a file is, of course, by redirecting
646the file to the standard input as in:
647
648@example
649mailutils dbm create file.db < input.txt
650@end example
651
652There is also a special option for that purpose: @option{--file}
653(@option{-f}).  Thus, the following command is equivalent to the one
654above:
655
656@example
657mailutils dbm create --file input.txt file.db
658@end example
659
660The @option{--file} option has the advantage that it allows, in
661conjunction with another options, for copying input file metadata
662(owner UID, GID and file mode) to the created database.  For example,
663the following command ensures that the created database file will have
664the same metadata as the input file:
665
666@example
667mailutils dbm create --file input.txt --copy-permissions file.db
668@end example
669
670The @option{--copy-permissions} (@option{-P}) option is the one that
671does the job.
672
673There are also other ways to control mode and ownership of the created
674database, which are described below.
675
676More advanced dump formats (e.g.  @samp{version 1.0} format) carry
677additional information about the file, including its original name,
678ownership and mode.  If input is in one of these formats, the file
679name argument becomes optional.  If it is not supplied, the name
680stored in the input stream will be used.  For example, supposing that
681the file @file{users.dump} is in format 1.0, the following command
682suffices to restore the original filename, ownership, mode and, of
683course, data:
684
685@example
686mailutils dbm create --file users.dump
687@end example
688
689@node Add Records to a Database
690@subsubsection Add Records to a Database
691The @option{add} subcommand adds records to a database.  Records are
692read from the standard input and must be formatted as for
693@option{create}:
694
695@example
696mailutils dbm add file.db
697@end example
698
699If the argument file does not exist, it will be created.
700
701Adding a record with a key which is already present in the database
702produces an error.  To replace existing records, use the
703@option{replace} subcommand instead.
704
705The same options that affect the behavior of @option{create} apply to
706@option{add} and @samp{replace} as well, e.g.:
707
708@example
709mailutils dbm replace --file input.txt --copy-permissions file.db
710@end example
711
712@node Delete Records
713@subsubsection Delete Records
714To delete records, use the @option{delete} subcommand.  It reads a
715list of keys to delete to be specified as arguments in the command
716line:
717
718@example
719mailutils dbm delete file.db foo bar
720@end example
721
722The command above will delete from @file{file.db} records with keys
723@samp{foo} and @samp{bar}.
724
725It is not an error to attempt to delete a key that does not exist in
726the database, although such use will produce a warning message.
727
728By default, keys are matched literally.  It is also possible to use
729various pattern matching techniques, depending on the option
730specified.
731
732The @option{--glob} (@option{-G}) option instructs the tool to use UNIX globbing pattern matching.  For example, the command below will delete all keys starting with @samp{foo} and ending with a decimal digit:
733
734@example
735mailutils dbm delete file.db 'foo*[0-9]'
736@end example
737
738@noindent
739(note the quoting necessary to prevent shell from interpreting the
740metacharacters itself).
741
742Another option, @option{--regex} (@option{-R}) instructs @command{mailutils}
743to treat supplied keys as extended regular expressions:
744
745@example
746mailutils dbm delete --regex file.db 'foo.*[0-9]@{1,3@}'
747@end example
748
749Both options are affected by the @option{--ignore-case} (@option{-i})
750option, which turns on case-insensitive matching.
751
752Using pattern matching to delete records can be a risky operation as
753selecting a wrong pattern will lead to removing wrong records.  It is
754recommended to first use the list mode described below to verify that
755the patterns match the right keys.
756
757@node List the Database
758@subsubsection List the Database
759The @option{list} command lists the content of the database:
760
761@example
762mailutils dbm list file.db
763@end example
764
765By default, entire content is listed on the standard output.
766
767If supplied more than one command line argument, this mode treats the
768rest of arguments after the database file name as the keys to look for
769and lists only records with these keys:
770
771@example
772$ mailutils dbm list file.db foo bar
773foo 1
774bar 56
775@end example
776
777The @option{--glob} and @option{--regex} options instruct the tool to
778use UNIX globbing or extended regular expression matching,
779correspondingly.  These were described in detail above.
780
781@node Dump the Database
782@subsubsection Dump the Database
783
784The @option{dump} subcommand dumps the database to the standard output
785in a format suitable for backup or sending over the network (a
786version 1.0 format).
787
788@example
789mailutils dbm dump file.db < file.dump
790@end example
791
792The produced file is suitable for input to the @option{create} (@option{load}) command.  Among other uses, it provides an easy way to convert databases between various formats supported by Mailutils.  For example this is how to convert the database file @file{file.db} to the GDBM database @file{new.db}:
793
794@example
795mailutils dbm dump file.db | mailutils dbm create gdbm://new.db
796@end example
797
798Both @option{list} and @option{dump} subcommands share the same set of
799options.  In fact, they are pretty similar, except that use different
800defaults.  The @option{list} subcommand is designed to produce a
801human-readable output, whereas the dump subcommand is oriented towards
802backup purposes.
803
804@node Dump Formats
805@subsubsection Dump Formats
806As of version @value{VERSION}, @command{mailutils dbm} supports two formats
807for dumping DBM databases.  Both formats are line-oriented.  Comments
808are introduced with a sharp (@samp{#}) sign in the column 0 of a line,
809followed by at least one white space character (space or tab).  Sharp
810sign followed by a colon (@samp{#:}) introduces a @dfn{pragmatic
811comment}, which carries some additional information to the loader.
812
813@anchor{dump version 0.0}
814The @dfn{version 0.0} format is suitable for databases whose records
815contain only ASCII data.  In this format, each record occupies a
816separate line, which consists of the key and value separated by a
817single @sc{tab} character.  Empty lines are ignored.  For example:
818
819@example
820$ mailutils list /etc/mail/users.db
821root    guessme
822smith   pAssword
823qed     fooBar
824@end example
825
826The output in version 0.0 format is human readable and can be used as
827input to the popauth utility (@FIXME-pxref{popauth}.  However, version 0.0
828has serious drawbacks.  First of all, it is not suitable for databases
829that contain binary data.  Secondly, it cannot properly handle keys
830beginning with a sharp sign or containing @sc{tab}.  The version 1.0
831format is free from these drawbacks.
832
833@anchor{dump version 1.0}
834The @dfn{version 1.0} dump format begins with a @dfn{header}
835containing important information about the file, such as its file
836name, ownership and file mode.  This information is stored in
837pragmatic comments and allows @command{mailutils dbm load} to easily recreate
838an exact copy of the file.  The following comments are defined:
839
840@table @asis
841@item #:version=1.0
842Indicates that the data that follow are in version 1.0 format.
843@item #:filename=@var{s}
844Original database file name, without directory parts.
845@item #:uid=@var{n}
846Owner UID.
847@item #:user=@var{s}
848Owner name.
849@item #:gid=@var{n}
850Owner GID
851@item #:group=@var{s}
852Owner group name.
853@item #:mode=@var{o}
854File mode in octal
855@end table
856
857Following this header are actual data.  Each record is output in two
858parts: key and value.  Each part begins with a @samp{#:len=@var{n}}
859construct on a line by itself, where @var{n} is the length of the data
860in decimal.  This line is followed by one or more lines of the actual
861data, encoded in base64.  The data are formatted so that each line
862does not exceed 76 bytes in length (not counting the terminating
863newline).  An example of this format follows:
864
865@example
866# Database dump file created by GNU Mailutils 2.99.93 on
867# Tue Nov  1 13:28:03 2011
868#:version=1.0
869#:file=users.db
870#:uid=0,user=root,gid=25,group=mail,mode=640
871#:len=6
872c21pdGgA
873#:len=9
874cEFzc3dvcmQA
875#:len=5
876cm9vdAA=
877#:len=8
878Z3Vlc3NtZQA=
879#:len=4
880cWVkAA==
881#:len=7
882Zm9vQmFyAA==
883@end example
884
885@node Dbm Exit Codes
886@subsubsection Dbm Exit Codes
887The table below summarizes exit codes used by @command{mailutils dbm}:
888
889@multitable @columnfractions 0.2 0.3 0.5
890@headitem Code  @tab Symbolic name @tab Meaning
891@item 0 @tab EX_OK @tab Successful termination
892@item 64 @tab EX_USAGE @tab Command line usage error
893@item 65 @tab EX_DATAERR @tab Error in user-supplied data: the input
894file is badly formatted, or some of the data supplied in the command
895line are invalid (e.g. user name, uid or the like), etc.
896@item 66 @tab EX_NOINPUT @tab Cannot open input file
897@item 67 @tab EX_NOUSER  @tab No such user or UID when trying to set
898output file ownership
899@item 69 @tab EX_UNAVAILABLE @tab Operation cannot be performed due to
900some kind of problem (e.g. access to the file denied, etc.)
901@item 70 @tab EX_SOFTWARE @tab Internal software error
902@item 74 @tab EX_IOERR @tab Input/output error
903@end multitable
904
905@node mailutils logger
906@subsection mailutils logger
907The @command{mailutils logger} tool logs information using Mailutils log facility.
908
909Syntax:
910
911@example
912mailutils logger [@var{options}] [@var{message}]
913@end example
914
915The @var{message} argument, if supplied, gives the text to log.  If not supplied, the utility reads lines of text from standard input or a file (if the @option{--file} option is given) and sends them to log:
916
917@example
918# Send text to log
919$ mailutils logger I am here
920# Log each line from file.txt
921$ mailutils logger --file file.txt
922# Read stdin and log it:
923$ mailutils logger
924@end example
925
926The default logging channel is bound to standard error.  To bind it to
927syslog, use the @option{--syslog} command line option.  In that case
928@command{mailutils} uses facility @samp{user} and priority @samp{err}.  You
929can change this by using the @option{--priority} (@option{-p}) option.
930Its argument is either a syslog facility name or facility and severity
931names separated by a dot.  For example, the following invocation will use
932facility @samp{auth}, severity @samp{info}:
933
934@example
935mailutils logger --priority auth.info
936@end example
937
938The syslog tag can be set using the @option{--tag} (@option{-t}) option:
939
940@example
941mailutils logger --tag myprog
942@end example
943
944The default tag is @samp{mu-logger}.
945
946The @option{--severity} (@option{-s}) option sets the Mailutils
947severity level.  Its argument can be any of the following:
948@samp{debug}, @samp{info}, @samp{notice}, @samp{warning},
949@samp{error}, @samp{crit}, @samp{alert}, @samp{emerg}.
950
951Finally, the @option{--locus} (@option{-l}) option binds log messages
952to a location in a file.  Its argument has the following syntax:
953
954@example
955@var{file}:@var{line}[:@var{col}]
956@end example
957
958@noindent
959where @var{file} is the file name, @var{line} is the line number and
960optional @var{col} is the column number in that file.
961
962For example, the following invocation:
963
964@example
965mailutils logger --locus mailutils.conf:34 Suspicious statement
966@end example
967
968will send the following to the log:
969
970@example
971mu-logger: mailutils.conf:34: Suspicious statement
972@end example
973
974@node mailutils pop
975@subsection mailutils pop
976The @command{mailutils pop} command invokes an interactive POP3 client shell.
977It reads commands from the standard input, executes them and displays
978the results on the standard output.  If the standard input is
979connected to a terminal, the readline and history facilities are
980enabled (provided that Mailutils is configured with GNU Readline).
981
982The @command{mailutils pop} commands form two major groups.  POP3 protocol
983commands interact with the remote POP3 server and display responses
984obtained from it.  These commands are named after their POP3
985equivalents.  Another group, @dfn{internal commands}, are used to
986configure the shell itself.
987
988@subsubheading POP protocol commands
989@table @asis
990@item connect [-tls] @var{hostname} [@var{port}]
991Open connection to @var{hostname}.  If the @option{-tls} option is
992given, TLS encryption (also known as POPS protocol) will be used.  If
993@var{port} argument is not given, the command uses port 110 for a
994plain POP connection or 995 for POPS (if @option{-tls} is given).
995
996@item stls
997Start TLS negotiation.  This command is valid only after successful
998unencrypted connection has been initiated (using @command{connect}
999without @option{-tls} argument).
1000
1001@item user @var{name}
1002Send user name to the server.  The @command{pass} command must follow.
1003
1004@item pass [@var{password}]
1005Send password.  This command is valid only after @command{user}.  If
1006the @var{password} argument is omitted, the shell will ask you to
1007enter it.  While entering, both echoing and history recording will be
1008disabled.  Use this to avoid compromising your password.
1009
1010@item apop @var{user} [@var{password}]
1011Authenticate with APOP.   If the @var{password} argument is omitted,
1012you will be asked to supply it.  While entering, both echoing and
1013history recording will be disabled.
1014
1015@item capa [-reread] [@var{name}...]
1016List server capabilities.  Any number of arguments is accepted.  If given, the shell will display only the named capabilities, otherwise it displays entire list.  By default @command{capa} reuses the response of its previous invocation (if there was any), instead of resending the @samp{CAPA} command to the server.  To force it do so, use the @option{-reread} option.
1017
1018@item noop
1019Send a @samp{NOOP} (@dfn{no operation}) command to the server.
1020
1021@item stat
1022Get the mailbox size and number of messages in it.
1023
1024@item uidl [@var{number}]
1025Shows unique message identifiers.  Without arguments, shows
1026identifiers for each message in the mailbox.  If @var{number} is
1027given, the command returns the UIDL of that particular message only.
1028
1029@item list [@var{number}]
1030Lists messages.  See above for the meaning of @var{number}.  Each line
1031of the produced listing contains describes a single message and
1032contains at least the message number and size in bytes.  Depending on
1033the POP3 server implementation, additional fields may be present.  For
1034example, Mailutils @command{pop3d} can also output number of lines in
1035the message in the additional third field.
1036
1037@item retr @var{number}
1038Retrieve a message.
1039
1040@item top @var{msgno} [@var{number}]
1041Display message headers and first @var{number} (default 5) of lines of its body.
1042
1043@item dele @var{number}
1044Mark message for deletion.
1045
1046@item rset
1047Remove deletion marks.
1048
1049@item quit
1050Quit pop3 session.
1051
1052@item disconnect
1053Close existing connection.
1054@end table
1055
1056@subsubheading Internal commands
1057@table @asis
1058@item verbose [on|off|mask|unmask] [secure [payload]]
1059Control output verbosity.  Without arguments the @command{verbose}
1060command shows current settings.
1061
1062The argument @samp{off} (the default) turns off all additional output.
1063The @samp{verbose on} command enables POP3 protocol tracing output.
1064Additional arguments can be used to provide more verbosity.  The
1065@samp{secure} argument enables display of user passwords in the trace
1066output and the @samp{payload} argument enables showing payload data
1067(e.g. response body sent in the reply to @samp{RETR} command, etc.)
1068Thus, the full diagnostics output is obtained by
1069
1070@example
1071verbose on secure payload
1072@end example
1073
1074The @samp{mask} and @samp{unmask} arguments allow to disable and
1075enable such additional verbosity.  For example, supposing the command
1076above is in action, the following command will suppress the display of
1077user passwords in the traces:
1078
1079@example
1080verbose mask secure
1081@end example
1082
1083Similarly, @command{verbose unmask secure} will turn it back again.
1084
1085@item prompt @var{string}
1086Set command prompt.  The argument can contain @dfn{variable
1087references} in any of the following forms:
1088
1089@example
1090$@var{name}
1091$@{@var{name}@}
1092@end example
1093
1094@noindent
1095where @var{name} is the variable name.  Such references are expanded
1096to the actual value of the variable at the time of expansion.  The
1097following variables are defined:
1098
1099@multitable @columnfractions 0.4 0.6
1100@headitem Variable @tab Expansion
1101@item user @tab Login name of the authenticated POP3 user.  If the session is not authenticated yet, expands to @samp{[nouser]}.
1102@item host @tab Name of the remote host, or @samp{[nohost]} if no
1103connection is established.
1104@item program-name @tab Name of the program, as typed on the command
1105line to invoke it.
1106@item canonical-program-name @tab @samp{mailutils}
1107@item package @tab @samp{Mailutils}
1108@item version @tab Mailutils version number (@value{VERSION})
1109@item status @tab Session status.  One of: @samp{disconnected},
1110@samp{connected} or @samp{logged in}.
1111@end multitable
1112
1113For example:
1114
1115@example
1116prompt "[$@{user@}@@$host "
1117@end example
1118
1119Notice the use of quotes to include the space character in the prompt.
1120
1121@item exit
1122Exit the program.
1123
1124@item help [@var{command}]
1125@itemx ? [@var{command}]
1126Without arguments displays a list of commands with possible arguments
1127and short descriptions.
1128
1129With one argument, displays a terse description for the given @var{command}.
1130
1131@item history
1132Shows command history.
1133@end table
1134
1135@node mailutils imap
1136@subsection mailutils imap
1137The @command{mailutils imap} command invokes an interactive IMAP4 client
1138shell.  It reads commands from the standard input, executes them and
1139displays the results on the standard output.  The shell is similar to
1140the @command{mailutils pop} (@pxref{mailutils pop}) shell.
1141
1142@subsubheading IMAP protocol commands
1143
1144Most commands in this group correspond (with minor differences) to
1145IMAP commands described in RFC 3501@footnote{See
1146@uref{http://www.faqs.org/rfcs/rfc3501.html}.}.
1147
1148@deffn {imap command} connect [-tls] @var{host} [@var{port}]
1149Opens connection to the server @var{host}.  If the @option{-tls}
1150option is given, TLS encryption (also known as IMAPS protocol) will be
1151used.  If @var{port} argument is not supplied, the command uses port
1152143 for a plain IMAP connection or 993 for IMAPS (if @option{-tls} is
1153given).
1154@end deffn
1155
1156@deffn {imap command} capability [-reread] [@var{name}...]
1157Lists server capabilities.  Any number of @var{name}s is accepted.  If
1158at least one is given, the shell will display only the named
1159capabilities, otherwise it displays the entire list.  By default,
1160@command{capability} reuses the response of its previous invocation
1161(if there was any), instead of resending the CAPABILITY command to the
1162server.  To force it do so, use the @option{-reread} option.
1163@end deffn
1164
1165@deffn {imap command} starttls
1166Starts TLS negotiation.  This command is valid only after unencrypted
1167connection has been successfully initiated using connect without the
1168@option{-tls} option.
1169@end deffn
1170
1171@deffn {imap command} login @var{user} [@var{password}]
1172Logs in to the server as @var{user} with optional @var{password}.  If
1173the pass argument is omitted, the shell will ask you to enter it.
1174While entering, both echoing and history recording will be disabled.
1175Use this to avoid compromising your password.
1176@end deffn
1177
1178@deffn {imap command} logout
1179@deffnx {imap command} quit
1180Quits the imap session.
1181@end deffn
1182
1183@deffn {imap command} id [-test @var{kw}] [@var{arg}...]
1184Sends IMAP ID command.  See RFC
11852971@footnote{@uref{http://www.faqs.org/rfcs/rfc2971.html}}, for a
1186discussion of arguments.  By default, this command outputs entire ID
1187list. If, however, the @option{-test} option is given, it will check whether
1188the keyword @var{kw} is defined and display its value if so.
1189@end deffn
1190
1191@deffn {imap command} check
1192Requests a server checkpoint.
1193@end deffn
1194
1195@deffn {imap command} select [@var{mbox}]
1196Selects the named mailbox. Without argument, selects @samp{INBOX}.
1197@end deffn
1198
1199@deffn {imap command} examine [@var{mbox}]
1200Examines the named mailbox, i.e. selects it in read-only mode.  If
1201@var{mbox} is not given, @samp{INBOX} is assumed.
1202@end deffn
1203
1204@deffn {imap command} status @var{mbox} @var{kw} [@var{kw}...]
1205Gets mailbox status.  Valid keywords (@var{kw} arguments) are:
1206@samp{MESSAGES}, @samp{RECENT}, @samp{UIDNEXT}, @samp{UIDVALIDITY},
1207and @samp{UNSEEN}.  Keywords are case-insensitive.
1208@end deffn
1209
1210@deffn {imap command} fetch @var{msgset} @var{items}
1211Fetches message data.  See RFC 3501, section
12126.4.5@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.4.5}},
1213for a discussion of its arguments.
1214@end deffn
1215
1216@deffn {imap command} store @var{msgset} @var{items}
1217Alters mailbox data.  See RFC 3501, section
12186.4.6@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.4.6}},
1219for a discussion of its arguments.
1220@end deffn
1221
1222@deffn {imap command} close
1223Closes the currently selected mailbox (with expunge).
1224@end deffn
1225
1226@deffn {imap command} unselect
1227Closes the currently selected mailbox (without expunge).
1228@end deffn
1229
1230@deffn {imap command} delete @var{mbox}
1231Deletes the mailbox @var{mbox}.
1232@end deffn
1233
1234@deffn {imap command} rename @var{old-name} @var{new-name}
1235Renames existing mailbox @var{old-name} to @var{new-name}.
1236@end deffn
1237
1238@deffn {imap command} expunge
1239Permanently removes messages marked for deletion.
1240@end deffn
1241
1242@deffn {imap command} create @var{name}
1243Creates new mailbox with the given @var{name}.
1244@end deffn
1245
1246@deffn {imap command} append [-time @var{datetime}] [-flag @var{flag}] @var{mailbox} @var{file}
1247Reads an RFC-822 message from @var{file} and appends it to the
1248@var{mailbox}.  Use the @option{-time} option to supply envelope date
1249for the message.  Use the @option{-flag} option to supply message
1250flags.  For example:
1251
1252@example
1253append -time "25-Aug-2002 18:00:00 +0200" -flag \Seen INBOX input.msg
1254@end example
1255@end deffn
1256
1257@deffn {imap command} list @var{ref} @var{mbox}
1258Lists matching mailboxes.  See RFC 3501, section
12596.3.8@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.3.8}},
1260for a discussion of its arguments.
1261@end deffn
1262
1263@deffn {imap command} lsub @var{ref} @var{mbox}
1264Lists subscribed mailboxes (RFC 3501, section 6.3.9@footnote{@uref{http://tools.ietf.org/html/rfc3501#section-6.3.9}}).
1265@end deffn
1266
1267@deffn {imap command} subscribe @var{mbox}
1268Subscribes to a mailbox.
1269@end deffn
1270
1271@deffn {imap command} unsubscribe @var{mbox}
1272Removes mailbox @var{mbox} from the subscription list.
1273@end deffn
1274
1275@deffn {imap command} noop
1276Sends a @dfn{no operation} command.
1277@end deffn
1278
1279@deffn {imap command} disconnect
1280Closes existing connection.
1281@end deffn
1282
1283@subsubheading Internal commands
1284The @code{imap} shell implements the same set of internal commands as
1285@code{pop} shell: @xref{mailutils pop, Internal commands}.  There is
1286only one imap-specific internal command:
1287
1288@deffn {imap command} uid [on|off]
1289Controls the UID mode.  When the UID mode is on, the commands
1290@code{fetch} and @code{store} operate on and return message UIDs
1291instead of their sequence numbers.
1292
1293To examine the current state of the UID mode, issue the @code{uid}
1294command without arguments.
1295@end deffn
1296
1297@node mailutils send
1298@subsection mailutils send
1299Reads an RFC-822 message from a file and sends it over to a specified
1300SMTP server.  The syntax is:
1301
1302@example
1303mailutils send [@var{options}] @var{host} @var{file}
1304@end example
1305
1306@noindent
1307where @var{host} defines the SMTP server through which to send the
1308message, and @var{file} is the name of the input file containing the
1309message.  For example, to send a message from file @file{input.msg}
1310using SMTP service at localhost, one would write:
1311
1312@example
1313$ mailutils send localhost input.msg
1314@end example
1315
1316The @var{host} argument can be an IP address, hostname, or a
1317valid SMTP URL.
1318
1319The following command line options are understood:
1320
1321@table @option
1322@item -F @var{address}
1323@itemx --from=@var{address}
1324Supplies envelope sender address.
1325
1326@item -T @var{address}
1327@itemx --rcpt=@var{address}
1328Supplies envelope recipient address.  It can be specified multiple
1329times.
1330
1331@item -t
1332@itemx --read-recipients
1333Instructs the program to read recipient email addresses from the
1334message @samp{To:}, @samp{Cc:}, and @samp{Bcc:} headers.
1335@end table
1336
1337@node mailutils smtp
1338@subsection mailutils smtp
1339The @code{mailutils smtp} command invokes an interactive SMTP client
1340shell.  It reads commands from the standard input, executes them and
1341displays the results on the standard output.  If the standard input is
1342connected to a terminal, the readline and history facilities are
1343enabled (provided that Mailutils is configured with GNU Readline).
1344
1345@subsubheading Initializing connection
1346
1347@deffn {smtp command} connect [-tls] @var{host} [@var{port}]
1348Connects to SMTP server at @var{host} (IP address or host name).  If
1349the @option{-tls} option is given, TLS encryption (also known as SMTPS
1350protocol) will be used.  The default port number is 25 for plain SMTP
1351and 465 for SMTPS.  Explicit @var{port} argument overrides the default
1352value.
1353@end deffn
1354
1355@subsubheading Connection parameters
1356
1357A number of parameters is associated with an open connection:
1358
1359@table @asis
1360@item domain
1361Domain name used in EHLO statement.  Defaults to the current host name.
1362@end table
1363
1364The following parameters are used for ESMTP authentication:
1365
1366@table @asis
1367@item username
1368User name.
1369@item password
1370User password.
1371@item service
1372GSASL service name.
1373@item realm
1374Realm name.
1375@item host
1376Host name.
1377@item url
1378SMTP URL.  It can contain all of the above. Default is smtp://
1379@end table
1380
1381These parameters are manipulated using the following statements:
1382
1383@deffn {smtp command} set @var{param} @var{value} [@var{param} @var{value}...]
1384Sets parameter @var{param} to @var{value}.  Several parameters can be
1385set with one @command{set} statement.
1386@end deffn
1387
1388@deffn {smtp command} clear [@var{param}...]
1389Unset the supplied connection parameters.  If used without arguments,
1390unsets all parameters.
1391@end deffn
1392
1393@deffn {smtp command} list [@var{param}...]
1394Lists the values of the connection parameters.  If used without
1395arguments, lists all parameters.
1396@end deffn
1397
1398@subsubheading SMTP commands
1399@deffn {smtp command} ehlo [@var{domain}]
1400Sends the ESMTP greeting.  Unless @var{domain} is supplied, the
1401connection parameter @samp{domain} is used.
1402@end deffn
1403
1404@deffn {smtp command} capa [@var{name}...]
1405Lists the server capabilities.
1406@end deffn
1407
1408@deffn {smtp command} starttls
1409Initiates encrypted connection.  This command is disabled if the
1410connection is opened with the @option{-tls} option.
1411@end deffn
1412
1413@deffn {smtp command} auth @var{mech} [@var{mech}...]
1414Authenticate using the supplied mechanisms.
1415@end deffn
1416
1417@deffn {smtp command} rset
1418Reset the session state.
1419@end deffn
1420
1421@deffn {smtp command} from [@var{email}]
1422Sets sender email address.  If used without arguments, prints the
1423sender email address.
1424@end deffn
1425
1426@deffn {smtp command} to [@var{email}]
1427Sets recipient email address.  If used without arguments, prints all
1428recepient names collected so far.
1429@end deffn
1430
1431@deffn {smtp command} smtp @var{command} [@var{args}...]
1432Sends the @var{command} with its arguments verbatim.
1433@end deffn
1434
1435@deffn {smtp command} quit
1436Quits the SMTP session.
1437@end deffn
1438
1439@deffn {smtp command} send [@var{file}]
1440Reads the message from @var{file} and sends it.  If @var{file} is not
1441supplied, the action depends on whether a @code{send} command was used
1442prevously within the same session.  If so, @command{mailutils} will
1443first ask whether to reuse the already supplied message.  If not, it
1444will start an editor, allowing you to enter the new message.  When you
1445exit from the editor, you will be prompted what to do with the
1446message: send, edit, or quit (discard) it.
1447@end deffn
1448
1449@subsubheading Internal commands
1450
1451Internal commands are the same as in @code{pop} shell: @xref{mailutils
1452pop, Internal commands}.
1453
1454@node mailutils maildir_fixup
1455@subsection mailutils maildir_fixup
1456
1457This command fixes attributes and UID assignments in @samp{maildir}
1458mailboxes created by mailutils versions prior to 3.10.90.
1459
1460Attribute flags used in @samp{maildir} mailboxes by these versions of
1461mailutils were a bit different from those described in the original
1462description of the @samp{maildir} format@footnote{@uref{http://cr.yp.to/proto/maildir.html}}
1463and those used by another implementations.  The discrepancy has been
1464reported in the Mailutils bug tracker@footnote{@uref{http://savannah.gnu.org/bugs/?56428}}
1465and was fixed in version 3.10.90.  Along with this fix, measures has
1466been taken to ensure persistence of UID assignments between different
1467sessions.  Starting from version 3.10.90, whenever @command{mailutils}
1468library opens a maildir mailbox, it determines the version that
1469created it.  If the mailbox is writable and the library determines
1470that the mailbox is affected by the two problems described above, it
1471fixes the mailbox on the fly.  This process is completely transparent
1472to the user.
1473
1474If you operate a site with a large number of mailboxes in
1475@samp{maildir} formats, you may choose to fix up all of them at once.
1476That's what the @command{maildir_fixup} command is for.  It takes one
1477or more directory names as its arguments and recursively scans these
1478directories in search for @samp{maildir} mailboxes.  Each mailbox
1479found is analyzed and a fix-up is performed, if necessary.  If a
1480mailbox is already in the new format, it remains untouched.
1481
1482The following options modify the program's behavior:
1483
1484@table @option
1485@item -v
1486@itemx --verbose
1487List each maildir name before processing it.
1488
1489@item -n
1490@itemx --dry-run
1491Don't touch maildirs, just print their names,
1492@end table
1493
1494The @command{maildir_fixup} tool reads main mailutils configuration
1495file by default.  It looks for program-specific settings in the
1496section @samp{program maildir_fixup}.  If the @code{include} statement
1497is present that has a directory name as its argument, the file
1498@file{maildir_fixup} is looked up in that directory and parsed, if
1499present.
1500
1501The program uses the following configuration statements:
1502
1503@multitable @columnfractions 0.3 0.6
1504@headitem Statement @tab Reference
1505@item debug         @tab @xref{debug statement}.
1506@item locking       @tab @xref{locking statement}.
1507@item mandatory-locking @tab @FIXME-xref{mandatory-locking statement}.
1508@end multitable
1509
1510