xref: /openbsd-src/libexec/mail.local/mail.local.8 (revision 41ce3b17e73f6b7d2d9e1a3d961e4bab2d895cb5)
1.\"	$OpenBSD: mail.local.8,v 1.33 2022/03/31 17:27:19 naddy Exp $
2.\" Copyright (c) 1990 The Regents of the University of California.
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. Neither the name of the University nor the names of its contributors
14.\"    may be used to endorse or promote products derived from this software
15.\"    without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.\"	from: @(#)mail.local.8	6.8 (Berkeley) 4/27/91
30.\"
31.Dd $Mdocdate: March 31 2022 $
32.Dt MAIL.LOCAL 8
33.Os
34.Sh NAME
35.Nm mail.local
36.Nd store mail in a mailbox
37.Sh SYNOPSIS
38.Nm mail.local
39.Op Fl Ll
40.Op Fl f Ar from
41.Ar user ...
42.Sh DESCRIPTION
43.Nm
44reads the standard input up to an end-of-file and appends it to each
45.Ar user Ns 's
46.Pa mail
47file.
48The
49.Ar user
50must be a valid user name.
51.Pp
52The options are as follows:
53.Bl -tag -width Ds
54.It Fl f Ar from
55Specify the sender's name.
56.It Fl L
57Don't create a
58.Pa username.lock
59file while locking the spool.
60.It Fl l
61For compatibility, request that files named
62.Pa username.lock
63be used for locking.
64(This is the default behavior.)
65.El
66.Pp
67Individual mail messages in the mailbox are delimited by an empty
68line followed by a line beginning with the string
69.Dq "From\&\ " .
70A line containing the string
71.Dq "From\&\ " ,
72the sender's name and a timestamp is prepended to each delivered mail message.
73A blank line is appended to each message.
74A greater-than character
75.Pq Ql >
76is prepended to any line in the message which could be mistaken for a
77.Dq "From\&\ "
78delimiter line.
79.Pp
80Significant effort has been made to ensure that
81.Nm
82acts as securely as possible.
83It will only deliver to a mail spool directory that is not world-writable.
84The default mode of
85.Pa /var/mail
86on
87.Ox
88is 755, which prevents non-root processes from creating mail spool files.
89The MTA is expected to either create the mail spool file itself, or call
90.Nm
91as root.
92.Pp
93The mailbox is always locked using
94.Xr flock 2
95while mail is appended.
96Unless the
97.Fl L
98flag is specified, a
99.Pa username.lock
100file is also used.
101.Pp
102If the
103.Xr biff 1
104service is returned by
105.Xr getservbyname 3 ,
106the biff server is notified of delivered mail.
107.Sh ENVIRONMENT
108.Bl -tag -width indent
109.It Ev TZ
110Used to set the appropriate time zone on the timestamp.
111.El
112.Sh FILES
113.Bl -tag -width /tmp/local.XXXXXXXXXX -compact
114.It Pa /tmp/local.XXXXXXXXXX
115temporary files
116.It Pa /var/mail/user
117user's mailbox directory
118.El
119.Sh EXIT STATUS
120.Ex -std mail.local
121.Sh SEE ALSO
122.Xr biff 1 ,
123.Xr mail 1 ,
124.Xr flock 2 ,
125.Xr getservbyname 3 ,
126.Xr comsat 8 ,
127.Xr smtpd 8
128.Sh HISTORY
129A superset of
130.Nm
131(handling mailbox reading as well as mail delivery) appeared in
132.At v7
133as the program
134.Xr mail 1 .
135.Sh BUGS
136Using quotas in
137.Pa /var/mail
138can be problematic if using
139.Xr sendmail 8
140as an MTA,
141since it asks
142.Nm
143to deliver a message to multiple recipients if possible.
144This causes problems in a quota environment since a message may be
145delivered to some users but not others due to disk quotas.
146Even though the message was delivered to some of the recipients,
147.Nm
148will exit with an exit code > 0, causing
149.Xr sendmail 8
150to attempt redelivery later.
151That means that some users will keep getting the same message every time
152.Xr sendmail 8
153runs its queue.
154This problem does not exist for
155.Xr smtpd 8
156users.
157.Pp
158If you are running
159.Xr sendmail 8
160and have disk quotas on
161.Pa /var/mail ,
162it is imperative that you unset the
163.Dq m
164mailer flag for the
165.Sq local
166mailer.
167To do this, locate the line beginning with
168.Dq Mlocal
169in
170.Pa /etc/mail/sendmail.cf
171and remove the
172.Dq m
173from the flags section, denoted by
174.Dq F= .
175Alternately, you can override the default mailer flags by adding the line:
176.Pp
177.Dl define(`LOCAL_MAILER_FLAGS', `rn9S')dnl
178.Pp
179to your
180.Dq \.mc
181file (this is the source file that is used to generate
182.Pa /etc/mail/sendmail.cf ) .
183