summaryrefslogtreecommitdiffstats
path: root/maildrop/reformail.sgml
blob: 4413c3f09bfc255dda05a2d2d11e73ba5d6090be (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
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<!-- Copyright 1998 - 2007 Double Precision, Inc.  See COPYING for -->
<!-- distribution information. -->
<refentry id="reformail">
  <info><author><firstname>Sam</firstname><surname>Varshavchik</surname><contrib>Author</contrib></author><productname>Courier Mail Server</productname></info>

  <refmeta>
    <refentrytitle>reformail</refentrytitle>
    <manvolnum>1</manvolnum>
    <refmiscinfo class='manual'>Double Precision, Inc.</refmiscinfo>
  </refmeta>

  <refnamediv>
    <refname>reformail</refname>
    <refpurpose>E-mail reformatting tool</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis sepchar=" ">
      <command>reformail</command>
      <arg choice="plain" rep="norepeat">-s</arg>
      <arg choice="plain" rep="norepeat">command</arg>
      <arg choice="opt" rep="repeat">option</arg>
    </cmdsynopsis>

    <cmdsynopsis sepchar=" ">
      <command>reformail</command>
      <arg choice="plain" rep="norepeat">-D</arg>
      <arg choice="plain" rep="norepeat">len</arg>
      <arg choice="plain" rep="norepeat"><replaceable>filename</replaceable></arg>
    </cmdsynopsis>

    <cmdsynopsis sepchar=" ">
      <command>reformail</command>
      <arg choice="plain" rep="repeat">-x <replaceable>header:</replaceable></arg>
    </cmdsynopsis>

    <cmdsynopsis sepchar=" ">
      <command>reformail</command>
      <arg choice="plain" rep="repeat">-X <replaceable>header:</replaceable></arg>
    </cmdsynopsis>

    <cmdsynopsis sepchar=" ">
      <command>reformail</command>
      <arg rep="repeat" choice="opt"><replaceable>options</replaceable></arg>
    </cmdsynopsis>
    <sidebar>
      <simpara>See below for additional options</simpara>
    </sidebar>
  </refsynopsisdiv>

  <refsect1 id="reformail_description">
    <title>DESCRIPTION</title>

<para>
The <command>reformail</command> program reads a message on standard input,
reformats it
in some way, and writes the message to standard output:</para>

    <refsect2 id="reformail_splitting_mailboxes_into_individual_messages">
      <title>Splitting mailboxes into individual messages</title>

      <para>
The <option>-s</option> option splits the mbox-formatted mailbox file on
standard input into
individual messages.
An external program is executed for each
message. The contents of each individual message will be provided to the
external program on standard input.</para>

      <para>
If the <envar>FILENO</envar> environment variable is set to a number,
<command>reformail</command> will consecutively increment
<envar>FILENO</envar>
each time the program is executed for each individual
message.</para>

      <para>
If <envar>FILENO</envar> is not set, it's initial value will be "000".
If <envar>FILENO</envar> is set to a non-numeric value,
<envar>FILENO</envar> will remain unchanged.</para>
    </refsect2>

    <refsect2 id="reformail_detecting_duplicate_messages">
      <title>Detecting duplicate messages</title>

      <para>
The <option>-D</option> option implements a simple way to delete duplicate
messages in incoming mail. <replaceable>filename</replaceable> is a file that
will be approximately '<replaceable>len</replaceable>' bytes long.
This file will be used by
<command>reformail</command> to save message IDs seen in
recent mail.
<command>reformail</command> reads the message on standard input.
If the message has a <literal>Message-ID:</literal> header that's already in
the cache file,
<command>reformail</command> terminates with the exit code set to 0. Otherwise,
<command>reformail</command> terminates with the exit code set to 1.</para>
    <note>
      <para>
	Unlike a similar feature in the <command>formail</command> command,
	<command>reformail</command> takes care of locking
	the file, so it's not necessary to implement your own locking
	mechanism for this option.
      </para>
    </note>

    </refsect2>

    <refsect2 id="reformail_extracting_headers">
      <title>Extracting headers</title>

      <para>
The <option>-x</option> and <option>-X</option> options extract the indicated
headers from the message, and print them to standard output. Multiple
<option>-x</option> and <option>-X</option> options can be specified at
the same time, and may be intermixed.</para>

      <para>
The <option>-x</option> option extracts and prints the contents of the header.
The <option>-X</option> option prints the name of the header as well.</para>

      <para>In all other situations, <command>reformail</command>
copies the message on
its standard input to its standard output, reformatting the message as
follows:</para>
    </refsect2>
  </refsect1>

  <refsect1 id="reformail_options">
    <title>OPTIONS</title>

    <variablelist>
      <varlistentry>
	<term>-a'header: value'</term>
	<listitem>
	  <para>
Append a custom header to the message if this
header does not already exist. If the header is either
<literal>Message-ID:</literal> or
<literal>Resent-Message-ID:</literal> and the value is empty,
<command>reformail</command> generates
a (hopefully) unique message ID for you.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-A'header: value'</term>
	<listitem>
	  <para>
Append a custom header to the message even if this
header already exists. If the header is
either <literal>Message-ID:</literal> or
<literal>Resent-Message-ID:</literal>
and the value is empty, <command>reformail</command> generates
a (hopefully) unique message ID for you.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-c</term>
	<listitem>
	  <para>
Concatenate multi-line headers. Headers split on multiple lines are
combined into a single line.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-d<replaceable>n</replaceable></term>
	<listitem>
	  <para>
If n is <literal>1</literal>, each line will be terminated with CRLF.
If n is <literal>0</literal>
(default), each line will be terminated with LF.
<command>reformail</command> reads a
message with either line terminator, and will force the message to have
the specified line termination.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-f0</term>
	<listitem>
	  <para>
	    Any initial blank lines are removed. If the first non-blank
	    line is a
	    "<literal>From_</literal>" line, it gets converted to a
	    "Return-Path:" header, and any existing "Return-Path:" header
	    gets removed. If the message does not start with a 
	    "<literal>From_</literal>" line, the message remains unchanged.
	  </para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-f1</term>
	<listitem>
	  <para>
Add the "<literal>From_</literal>" line to the message, if it's not there.
<command>reformail</command> will attempt to generate the
"<literal>From_</literal>" line from any
<literal>Errors-To:</literal>, <literal>Return-Path:</literal>, or
<literal>From:</literal> headers in the message.
"<literal>root</literal>" will be used
if
<command>reformail</command> is unable to determine the return address.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-i'<replaceable>header: value</replaceable>'</term>
	<listitem>
	  <para>
Appends a custom header to the message. If this
header already exists it is renamed by prepending "<literal>Old-</literal>"
to the name of
the header.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-I'<replaceable>header: value</replaceable>'</term>
	<listitem>
	  <para>
Append a custom header to the message. If this
header already exists in the message, the old header is completely
removed. If the value is empty, any existing header is completely removed,
and nothing gets appended.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-R oldheader: newheader:</term>
	<listitem>
	  <para>
Rename the indicated header.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-u'header:'</term>
	<listitem>
	  <para>
If this header occurs multiple times in the message,
remove all occurrences except the first one.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term>-U'header:'</term>
	<listitem>
	  <para>
If this header occurs multiple times in the message,
remove all occurrences except the last one.</para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>

  <refsect1 id="reformail_autoreplies">
    <title>AUTOREPLIES</title>

    <anchor id="Autoreplies"/>
    <para>
      The autoreply options from earlier versions of <command>mailbot</command>
      have been moved into
      <ulink url="mailbot.html"><citerefentry><refentrytitle>mailbot</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>.
    </para>
  </refsect1>

  <refsect1 id="reformail_bugs">
    <title>BUGS</title>

    <para>
For the <option>-a</option>, <option>-A</option>, and <option>-I</option>
options, a space after the header name and the colon is
considered to be a non-empty field.</para>

    <para>
Do not provide the same header to more than one family of header-modifying
options, such as <option>-u</option>/<option>-U</option> and
<option>-a</option>/<option>-A</option>. Doing so yields unpredictable
results.
It's better to run <option>reformail</option> several times (use a pipe,
perhaps).</para>
  </refsect1>

  <refsect1 id="reformail_see_also">
    <title>SEE ALSO</title>

    <para>
<ulink url="courier.html"><citerefentry><refentrytitle>courier</refentrytitle><manvolnum>8</manvolnum></citerefentry></ulink>,
<citerefentry><refentrytitle>sendmail</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<ulink url="mailbot.html"><citerefentry><refentrytitle>mailbot</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>,
<ulink url="maildrop.html"><citerefentry><refentrytitle>maildrop</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>.
</para>
  </refsect1>
</refentry>