Replaced sendfiles with a simpler version that uses send instead of viamail.
[mmh] / man / mhstore.man1
1 .\"
2 .\" %nmhwarning%
3 .\"
4 .TH MHSTORE %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
5 .SH NAME
6 mhstore \- store contents of MIME messages into files
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B mhstore
11 .RI [ +folder ]
12 .RI [ msgs ]
13 .RB [ \-file
14 .IR file ]
15 .RB [ \-part
16 .IR number ]
17 \&...
18 .RB [ \-type
19 .IR content ]
20 \&...
21 .RB [ \-auto " | " \-noauto ]
22 .RB [ \-verbose " | " \-noverbose ]
23 .RB [ \-rcache
24 .IR policy ]
25 .RB [ \-wcache
26 .IR policy ]
27 .RB [ \-check " | " \-nocheck ]
28 .RB [ \-version ]
29 .RB [ \-help ]
30 .ad
31 .SH DESCRIPTION
32 The
33 .B mhstore
34 command allows you to store the contents of a
35 collection of MIME (multi-media) messages into files or other
36 messages.
37 .PP
38 .B mhstore
39 manipulates multi-media messages as specified in
40 RFC\-2045 thru RFC\-2049.
41 .PP
42 By default,
43 .B mhstore
44 will store all the parts of each message.
45 Each part will be store in a separate file.  The header fields of
46 the message are not stored.  By using the
47 .B \-part
48 and
49 .B \-type
50 switches, you may limit the scope of
51 .B mhstore
52 to particular
53 subparts (of a multipart content) and/or particular content types.
54 .PP
55 The option
56 .B \-file
57 .I file
58 directs
59 .B mhstore
60 to use the specified
61 file as the source message, rather than a message from a folder.
62 If you specify this file as \*(lq-\*(rq, then
63 .B mhstore
64 will
65 accept the source message on the standard input.  Note that the
66 file, or input from standard input should be a validly formatted
67 message, just like any other
68 .B nmh
69 message.  It should
70 .B NOT
71 be in mail drop format (to convert a file in mail drop format to
72 a folder of
73 .B nmh
74 messages, see
75 .BR inc (1)).
76 .PP
77 A part specification consists of a series of numbers separated by
78 dots.  For example, in a multipart content containing three parts,
79 these would be named as 1, 2, and 3, respectively.  If part 2 was
80 also a multipart content containing two parts, these would be named
81 as 2.1 and 2.2, respectively.  Note that the
82 .B \-part
83 switch is
84 effective for only messages containing a multipart content.  If a
85 message has some other kind of content, or if the part is itself
86 another multipart content, the
87 .B \-part
88 switch will not prevent
89 the content from being acted upon.
90 .PP
91 A content specification consists of a content type and a subtype.
92 The initial list of \*(lqstandard\*(rq content types and subtypes
93 can be found in RFC\-2046.
94 .PP
95 A list of commonly used contents is briefly reproduced here:
96 .PP
97 .RS 5
98 .nf
99 .ta \w'application  'u
100 Type    Subtypes
101 ----    --------
102 text    plain, enriched
103 multipart       mixed, alternative, digest, parallel
104 message rfc822, partial, external-body
105 application     octet-stream, postscript
106 image   jpeg, gif, png
107 audio   basic
108 video   mpeg
109 .fi
110 .RE
111 .PP
112 A legal MIME message must contain a subtype specification.
113 .PP
114 To specify a content, regardless of its subtype, just use the name
115 of the content, e.g., \*(lqaudio\*(rq.  To specify a specific
116 subtype, separate the two with a slash, e.g., \*(lqaudio/basic\*(rq.
117 Note that regardless of the values given to the
118 .B \-type
119 switch,
120 a multipart content (of any subtype listed above) is always acted
121 upon.  Further note that if the
122 .B \-type
123 switch is used, and it is
124 desirable to act on a message/external-body content, then the
125 .B \-type
126 switch must be used twice: once for message/external-body
127 and once for the content externally referenced.
128 .SS "Checking the Contents"
129 The
130 .B \-check
131 switch tells
132 .B mhstore
133 to check each content for
134 an integrity checksum.  If a content has such a checksum (specified
135 as a Content-MD5 header field), then
136 .B mhstore
137 will attempt to
138 verify the integrity of the content.
139 .SS "Storing the Contents"
140 The
141 .B mhstore
142 will store the contents of the named messages in
143 \*(lqnative\*(rq (decoded) format.  Two things must be determined:
144 the directory to store the content, and the filenames.  Files are
145 written in the directory given by the \*(lqnmh-storage\*(rq profile
146 entry, e.g.,
147 .PP
148 .RS 5
149 nmh-storage: /tmp
150 .RE
151 .PP
152 If this entry isn't present,
153 the current working directory is used.
154 .PP
155 If the
156 .B \-auto
157 switch is given, then
158 .B mhstore
159 will check if
160 the message contains information indicating the filename that should
161 be used to store the content.  This information should be specified
162 as the attribute \*(lqname=filename\*(rq in the \*(lqContent-Type\*(rq header
163 for the content you are storing.  For security reasons, this filename
164 will be ignored if it begins with the character '/', '.', '|', or '!',
165 or if it contains the character '%'.  For the sake of security,
166 this switch is not the default, and it is recommended that you do
167 NOT put the
168 .B \-auto
169 switch in your
170 .I \&.mmh/profile
171 file.
172 .PP
173 If the
174 .B \-auto
175 switch is not given (or is being ignored for security
176 reasons) then
177 .B mhstore
178 will look in the user's profile for a
179 \*(lqformatting string\*(rq to determine how the different contents
180 should be stored.  First,
181 .B mhstore
182 will look for an entry of
183 the form:
184 .PP
185 .RS 5
186 mhstore-store-<type>/<subtype>
187 .RE
188 .PP
189 to determine the formatting string.  If this isn't found,
190 .B mhstore
191 will look for an entry of the form:
192 .PP
193 .RS 5
194 mhstore-store-<type>
195 .RE
196 .PP
197 to determine the formatting string.
198 .PP
199 If the formatting string starts with a \*(lq+\*(rq character, then
200 content is stored in the named folder.  A formatting string consisting
201 solely of a \*(lq+\*(rq character is interpreted to be the current
202 folder.
203 .PP
204 If the formatting string consists solely of a \*(lq-\*(rq character,
205 then the content is sent to the standard output.
206 .PP
207 If the formatting string starts with a '|', then the display string
208 will represent a command for
209 .B mhstore
210 to execute which should
211 ultimately store the content.  The content will be passed to the
212 standard input of the command.  Before the command is executed,
213 .B mhstore
214 will change to the appropriate directory, and any
215 escapes (given below) in the display string will be expanded.
216 .PP
217 Otherwise the formatting string will represent a pathname in which
218 to store the content.  If the formatting string starts with a '/',
219 then the content will be stored in the full path given, else the
220 file name will be relative to the value of \*(lqnmh-storage\*(rq or
221 the current working directory.  Any escapes (given below) will be
222 expanded, except for the a-escape.
223 .PP
224 A command or pathname formatting string may contain the following
225 escapes.  If the content isn't part of a multipart (of any subtype
226 listed above) content, the p-escapes are ignored.
227 .PP
228 .RS 5
229 .nf
230 .ta \w'%P  'u
231 %a      Parameters from Content-type  (only valid with command)
232 %m      Insert message number
233 %P      Insert part number with leading dot
234 %p      Insert part number without leading dot
235 %t      Insert content type
236 %s      Insert content subtype
237 %%      Insert character %
238 .fi
239 .RE
240 .PP
241 If no formatting string is found,
242 .B mhstore
243 will check to see
244 if the content is application/octet-stream with parameter
245 \*(lqtype=tar\*(rq.  If so,
246 .B mhstore
247 will choose an appropriate
248 filename.  If the content is not application/octet-stream, then
249 .B mhstore
250 will check to see if the content is a message.  If
251 so,
252 .B mhstore
253 will use the value \*(lq+\*(rq.  As a last resort,
254 .B mhstore
255 will use the value \*(lq%m%P.%s\*(rq.
256 .PP
257 Example profile entries might be:
258 .PP
259 .RS 5
260 .nf
261 mhstore-store-text: %m%P.txt
262 mhstore-store-text: +inbox
263 mhstore-store-message/partial: +
264 mhstore-store-audio/basic: | raw2audio -e ulaw -s 8000 -c 1 > %m%P.au
265 mhstore-store-image/jpeg: %m%P.jpg
266 mhstore-store-application/PostScript: %m%P.ps
267 .fi
268 .RE
269 .PP
270 .SS "Reassembling Messages of Type message/partial"
271 .B mhstore
272 is also able to reassemble messages that have been
273 split into multiple messages of type \*(lqmessage/partial\*(rq.
274 .PP
275 When asked to store a content containing a partial message,
276 .B mhstore
277 will try to locate all of the portions and combine
278 them accordingly.  The default is to store the combined parts as
279 a new message in the current folder, although this can be changed
280 using formatting strings as discussed above.  Thus, if someone has
281 sent you a message in several parts (such as the output from
282 .BR sendfiles ),
283 you can easily reassemble them all into a single
284 message in the following fashion:
285 .PP
286 .RS 5
287 .nf
288 % mhlist 5-8
289  msg part  type/subtype             size description
290    5       message/partial           47K part 1 of 4
291    6       message/partial           47K part 2 of 4
292    7       message/partial           47K part 3 of 4
293    8       message/partial           18K part 4 of 4
294 % mhstore 5-8
295 reassembling partials 5,6,7,8 to folder inbox as message 9
296 % mhlist -verbose 9
297  msg part  type/subtype             size description
298    9       application/octet-stream 118K
299              (extract with uncompress | tar xvpf -)
300              type=tar
301              conversions=compress
302 .fi
303 .RE
304 .PP
305 This will store exactly one message, containing the sum of the
306 parts.  It doesn't matter whether the partials are specified in
307 order, since
308 .B mhstore
309 will sort the partials, so that they
310 are combined in the correct order.  But if
311 .B mhstore
312 can not
313 locate every partial necessary to reassemble the message, it will
314 not store anything.
315 RE
316 .PP
317 By using the
318 .B \-auto
319 switch,
320 .B mhstore
321 will automatically do the extraction for you:
322 .PP
323 .RS 5
324 .nf
325 % mhlist 5-8
326  msg part  type/subtype             size description
327    5       message/partial           47K part 1 of 4
328    6       message/partial           47K part 2 of 4
329    7       message/partial           47K part 3 of 4
330    8       message/partial           18K part 4 of 4
331 % mhstore 5-8
332 reassembling partials 5,6,7,8 to folder inbox as message 9
333 % mhlist -verbose 9
334  msg part  type/subtype             size description
335    9       application/octet-stream 118K
336              (extract with uncompress | tar xvpf -)
337              type=tar
338              conversions=compress
339 % mhstore -auto 9
340 -- tar listing appears here as files are extracted
341 .fi
342 .RE
343 .PP
344 As the second
345 .B tar
346 listing is generated, the files are extracted.
347 A prudent user will never put
348 .B \-auto
349 in the profile.
350 The correct procedure is to first use
351 .B mhlist
352 to find out what will be extracted.  Then
353 .B mhstore
354 can be invoked with
355 .B \-auto
356 to perform the extraction.
357 .SS "External Access"
358 For contents of type message/external-body,
359 \fImhstore\fR supports these access-types:
360 .PP
361 .IP \(bu 4
362 afs
363 .IP \(bu 4
364 anon-ftp
365 .IP \(bu 4
366 ftp
367 .IP \(bu 4
368 local-file
369 .IP \(bu 4
370 mail-server
371 .PP
372 For the \*(lqanon-ftp\*(rq and \*(lqftp\*(rq access types,
373 .B mhstore
374 will look for the \*(lqnmh-access-ftp\*(rq
375 profile entry, e.g.,
376 .PP
377 .RS 5
378 nmh-access-ftp: myftp.sh
379 .RE
380 .PP
381 to determine the pathname of a program to perform the FTP retrieval.
382 This program is invoked with these arguments:
383 .PP
384 .RS 5
385 .nf
386 domain name of FTP-site
387 username
388 password
389 remote directory
390 remote filename
391 local filename
392 \*(lqascii\*(rq or \*(lqbinary\*(rq
393 .fi
394 .RE
395 .PP
396 The program should terminate with an exit status of zero if the
397 retrieval is successful, and a non-zero exit status otherwise.
398 .SS "The Content Cache"
399 When
400 .B mhstore
401 encounters an external content containing a
402 \*(lqContent-ID:\*(rq field, and if the content allows caching, then
403 depending on the caching behavior of
404 .BR mhstore ,
405 the content might be read from or written to a cache.
406 .PP
407 The caching behavior of
408 .B mhstore
409 is controlled with the
410 .B \-rcache
411 and
412 .B \-wcache
413 switches, which define the policy for reading from,
414 and writing to, the cache, respectively.  One of four policies may be
415 specified: \*(lqpublic\*(rq, indicating that
416 .B mhstore
417 should make use
418 of a publically-accessible content cache; \*(lqprivate\*(rq, indicating
419 that
420 .B mhstore
421 should make use of the user's private content cache;
422 \*(lqnever\*(rq, indicating that
423 .B mhstore
424 should never make use of
425 caching; and, \*(lqask\*(rq, indicating that
426 .B mhstore
427 should ask the user.
428 .PP
429 There are two directories where contents may be cached: the profile entry
430 \*(lqnmh-cache\*(rq names a directory containing world-readable contents, and,
431 the profile entry \*(lqnmh-private-cache\*(rq names a directory containing
432 private contents.  The former should be an absolute (rooted) directory
433 name.
434 .PP
435 For example,
436 .PP
437 .RS 5
438 nmh-cache: /tmp
439 .RE
440 .PP
441 might be used if you didn't care that the cache got wiped after each
442 reboot of the system.  The private chace is interpreted relative to the user's
443 mail storage, if not rooted, e.g.,
444 .PP
445 .RS 5
446 nmh-private-cache: .cache
447 .RE
448 .PP
449 (which is the default value).
450 .SS "User Environment"
451 Because the display environment in which
452 .B mhstore
453 operates may vary for
454 different machines,
455 .B mhstore
456 will look for the environment variable
457 .BR $MHSTORE .
458 If present, this specifies the name of an additional
459 user profile which should be read.  Hence, when a user logs in on a
460 particular machine, this environment variable should be set to
461 refer to a file containing definitions useful for that machine.
462 Finally,
463 .B mhstore
464 will attempt to consult one other additional
465 user profile, e.g.,
466 .PP
467 .RS 5
468 %etcdir%/mhn.defaults
469 .RE
470 .PP
471 which is created automatically during
472 .B nmh
473 installation.
474
475 .SH FILES
476 .fc ^ ~
477 .nf
478 .ta \w'%etcdir%/ExtraBigFileName  'u
479 ^$HOME/.mmh/profile~^The user profile
480 ^$MHSTORE~^Additional profile entries
481 ^%etcdir%/mhn.defaults~^System default MIME profile entries
482 .fi
483
484 .SH "PROFILE COMPONENTS"
485 .fc ^ ~
486 .nf
487 .ta 2.4i
488 .ta \w'ExtraBigProfileName  'u
489 ^Path:~^To determine the user's mail storage
490 ^Current\-Folder:~^To find the default current folder
491 ^nmh-access-ftp:~^Program to retrieve contents via FTP
492 ^nmh-cache~^Public directory to store cached external contents
493 ^nmh-private-cache~^Personal directory to store cached external contents
494 ^nmh-storage~^Directory to store contents
495 ^mhstore-store-<type>*~^Template for storing contents
496 .fi
497
498 .SH "SEE ALSO"
499 mhbuild(1), mhlist(1), mhshow(1), sendfiles(1)
500
501 .SH DEFAULTS
502 .nf
503 .RB ` +folder "' defaults to the current folder"
504 .RB ` msgs "' defaults to cur"
505 .RB ` \-noauto '
506 .RB ` \-nocheck '
507 .RB ` \-rcache ask '
508 .RB ` \-wcache ask '
509 .RB ` \-noverbose '
510
511 .SH CONTEXT
512 If a folder is given, it will become the current folder.  The last
513 message selected will become the current message.
514
515 .SH BUGS
516 Partial messages contained within a multipart content are not reassembled.