summaryrefslogtreecommitdiff
path: root/doc/nullmailer-inject.1
blob: 26a7c1c4012c4086ecd3d4ee087559144cb4e0f3 (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
.TH nullmailer-inject 1
.SH NAME
nullmailer-inject \- Reformat and inject a message into the queue.
.SH SYNOPSIS
.B nullmailer-inject
[\-a]
[\-b]
[\-e]
[\-f sender]
[\-h]
.I [recipient [recipient ...]]
.SH DESCRIPTION
This program reads a email message from standard input, reformats its
header to comply with RFC822, and sends the resulting message to the
queue.
.SS HEADER FIELDS
The following lines are parsed for recipient addresses:
.IR To ,
.IR Cc ,
.IR Bcc ,
.IR Apparently-To ,
.IR Resent-To ,
.IR Resent-Cc ,
and
.IR Resent-Bcc .

The following sender address lines are parsed and rewritten:
.IR Sender ,
.IR From ,
.IR Reply-To ,
.IR Return-Path ,
.IR Return-Receipt-To ,
.IR Errors-To ,
.IR Resent-Sender ,
.IR Resent-From ,
and
.IR Resent-Reply-To .
If the
.I Return-Path
header field is present and contains a single address, its contents
will be used to set the envelope sender address.

If the message contains any of the following fields, it is treated as
a resent message:
.IR Resent-Sender ,
.IR Resent-From ,
.IR Resent-Reply-To ,
.IR Resent-To ,
.IR Resent-Cc ,
.IR Resent-Bcc ,
.IR Resent-Date ,
.IR Resent-Message-ID .
If the message is resent, only the recipient fields prefixed with
.I Resent-
are examined for addresses.

Any occurrences of
.IR Bcc ,
.IR Resent-Bcc ,
.IR Return-Path ,
or
.I Content-Length
are discarded after they are parsed (if necessary).

If the header lacks a
.I Message-Id
field, a unique string is generated and added to the message.
If the header lacks a
.I Date
field, the current local date and time in RFC822 format is appended to
the message.
If the message has no
.I To
or
.I Cc
fields, the following line is appended to the message:

.EX
	Cc: recipient list not shown: ;
.EE
.SS ADDRESS LISTS
Address lists are expected to follow the syntax set out in RFC822.
The following is a simplified explanation of the syntax.

An address list is list of addresses separated by commas.
An individual address may have one of the following three forms:
.IR user@fqdn ,
.IR comment <user@fqdn> ,
or
.IR phrase: address-list; .
Any of the first two forms may be used within the address list of the
third form.
Any word containing special characters must be placed in double quotes
and the special characters must be preceded with a backslash.
Comments may be placed between addresses in parenthesis.
All comments are ignored.

Addresses lists are reformatted as they are parsed for ease of later
re-parsing when the message reaches the destination(s).
If an address is missing a fqdn,
.B nullmailer-inject
adds one.
.SH OPTIONS
.TP
.I \-a
Use only the command line arguments as recipient addresses.
Ignore the header recipient lines.
.TP
.I \-b
Use both the command line arguments and data from the message header
as recipient addresses.
.TP
.I \-e
Use either the command line arguments (if there are any) or data from
the message header (if there are no arguments) as the recipient
addresses.
.TP
.I \-f sender
Set the envelope sender address to
.IR sender .
.TP
.I \-h
Use only data from the message header as the recipient addresses.
.TP
.I \-n
Do not queue the message, but print the reformatted contents to
standard output.
.TP
.I \-v
Print out the envelope (sender and recipient addresses) preceding the
message when printing the message to standard output.
.SH RETURN VALUE
Exits 0 if it was successful, otherwise it prints a diagnostic message
to standard error and exits 1.
.SH ENVIRONMENT
The environment variable
.BR NULLMAILER_FLAGS
is parsed and the behavior of
.B nullmailer-inject
is modified if any of the following letters are present:
.TP
.B c
Use "address (comment)" style in the generated
.B From
field instead of the default "comment <address>" style.
.TP
.B f
Ignore and remove any
.B From
header lines and always insert a generated one.
.TP
.B i
Ignore and remove any
.B Message-Id
header lines.
.TP
.B s
Ignore and remove any
.B Return-Path
header lines.
.TP
.B t
Insert a
.BR To
line containing a list of the recipients if the header does not
contain either a
.B To
or a
.B Cc
field.
If the message is determined to be a resent message (see above), a
.B Resent-To
field is added if the header does not contain either a
.BR Resent-To
or a
.BR Resent-Cc
field.
.PP
The user name is set by
.BR NULLMAILER_USER ,
.BR MAILUSER ,
.BR USER ,
or
.BR LOGNAME ,
whichever comes first.  If none of the above are set the name is taken
from the password file, or set to
.I unknown
if that fails.

The host name is set by the canonicalized value of
.BR NULLMAILER_HOST ,
.BR MAILHOST ,
or
.BR HOSTNAME ,
whichever comes first, or the
.I defaulthost
config file if none of the above are set (see below).

The full name of the user is set by
.BR NULLMAILER_NAME ,
.BR MAILNAME ,
or
.BR NAME ,
whichever comes first.

The user and host name of the envelope sender default to the user and
host name set above, but may be overridden by
.BR NULLMAILER_SUSER
and
.BR NULLMAILER_SHOST .

If
.BR NULLMAILER_QUEUE
is set, the program named is used in place of
.B nullmailer-queue
to queue the formatted message.
.SH CONTROL FILES
When reading the following files, a single line is read and stripped
of all leading and trailing whitespace characters.
.TP
.B defaultdomain
The content of this file is appended to any host name that does not
contain a period (except
.BR localhost ),
including
.I defaulthost
and
.IR idhost .
Defaults to the value of the
.B /etc/mailname
system file, if it exists, otherwise the literal name
.BR defauldomain .
.TP
.B defaulthost
The content of this file is appended to any address that is missing a
host name.
Defaults to the value of the
.I /etc/mailname
system file, if it exists, otherwise the literal name
.BR defaulthost .
.TP
.B idhost
The content of this file is used when building the message-id string
for the message.
Defaults to the canonicalized value of
.IR defaulthost .
.TP
.B /etc/mailname
The fully-qualifiled host name of the computer running nullmailer.
Defaults to the literal name
.BR me .
.SH SEE ALSO
nullmailer-queue(8)
.SH NOTES
This document glosses over very many details of how address parsing
and rewriting actually works (among other things).