xref: /openbsd/usr.sbin/smtpd/makemap.8 (revision cecf84d4)
1.\"	$OpenBSD: makemap.8,v 1.23 2014/09/16 21:18:19 jmc Exp $
2.\"
3.\" Copyright (c) 2009 Jacek Masiulaniec <jacekm@openbsd.org>
4.\" Copyright (c) 2008-2009 Gilles Chehade <gilles@poolp.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: September 16 2014 $
19.Dt MAKEMAP 8
20.Os
21.Sh NAME
22.Nm makemap
23.Nd create database maps for smtpd
24.Sh SYNOPSIS
25.Nm makemap
26.Op Fl o Ar dbfile
27.Op Fl t Ar type
28.Ar file
29.Sh DESCRIPTION
30Maps provide a generic interface for associating textual key to a value.
31Such associations may be accessed through a plaintext file, database, or DNS.
32The format of these file types is described below.
33.Nm
34itself creates the database maps used by keyed map lookups specified in
35.Xr smtpd.conf 5 .
36.Pp
37.Nm
38reads input from
39.Ar file
40and writes data to a file whose name is made by adding a
41.Dq .db
42suffix to
43.Ar file .
44In all cases,
45.Nm
46reads lines consisting of words separated by whitespace.
47The first word of a line is the database key;
48the remainder represents the mapped value.
49The database key and value may optionally be separated
50by the colon character.
51.Pp
52The options are as follows:
53.Bl -tag -width Ds
54.It Fl o Ar dbfile
55Write the generated database to
56.Ar dbfile .
57.It Fl t Ar type
58Specify the format of the resulting map file.
59The default map format is suitable for storing simple, unstructured,
60key-to-value string associations.
61However, if the mapped value has special meaning,
62as in the case of the virtual domains file,
63a suitable
64.Ar type
65must be provided.
66The available output types are:
67.Bl -tag -width "aliases"
68.It Cm aliases
69The mapped value is a comma-separated list of mail destinations.
70This format can be used for building user aliases and
71user mappings for virtual domain files.
72.It Cm set
73There is no mapped value \(en a map of this type will only allow for
74the lookup of keys.
75This format can be used for building primary domain maps.
76.El
77.El
78.Sh PRIMARY DOMAINS
79Primary domains can be kept in tables.
80To create a primary domain table, add each primary domain on a
81single line by itself.
82.Pp
83In addition to adding an entry to the primary domain map,
84one must add a filter rule that accepts mail for the domain
85map, for example:
86.Bd -literal -offset indent
87table domains "/etc/mail/domains"
88accept for domain <domains> deliver to mbox
89.Ed
90.Sh VIRTUAL DOMAINS
91Virtual domains may also be kept in tables.
92To create a virtual domain table, add each virtual domain on a
93single line by itself.
94.Pp
95Virtual domains expect a mapping of virtual users to real users
96in order to determine if a recipient is accepted or not.
97The mapping format is an extension to
98.Xr aliases 5 ,
99which allows the use of
100.Dq user@domain.tld
101to accept user only on the specified domain,
102.Dq user
103to accept the user for any of the virtual domains,
104.Dq @domain.tld
105to provide a catch-all for the specified domain and
106.Dq @
107to provide a global catch-all for all domains.
108.Xr smtpd 8
109will perform the lookups in that specific order.
110.Pp
111To create single virtual address, add
112.Dq user@example.com user
113to the users map.
114To handle all mail destined to any user at example.com, add
115.Dq @example.com user
116to the virtual map.
117.Pp
118In addition to adding an entry to the virtual map,
119one must add a filter rule that accepts mail for virtual domains,
120for example:
121.Bd -literal -offset indent
122table vdomains "/etc/mail/vdomains"
123table vusers "/etc/mail/users"
124
125accept for domain <vdomains> virtual <vusers> deliver to mbox
126accept for domain example.org virtual <vusers> deliver to mbox
127.Ed
128.Sh FILES
129.Bl -tag -width "/etc/mail/aliasesXXX" -compact
130.It Pa /etc/mail/aliases
131List of user mail aliases.
132.It Pa /etc/mail/secrets
133List of remote host credentials.
134.El
135.Sh EXIT STATUS
136.Ex -std makemap
137.Sh SEE ALSO
138.Xr aliases 5 ,
139.Xr smtpd.conf 5 ,
140.Xr newaliases 8 ,
141.Xr smtpd 8
142.Sh HISTORY
143The
144.Nm
145command first appeared in
146.Ox 4.6
147as a replacement for the equivalent command shipped with sendmail.
148