1.\" $OpenBSD: makemap.8,v 1.31 2021/02/13 07:37:13 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: February 13 2021 $ 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 U 27.Op Fl d Ar dbtype 28.Op Fl o Ar dbfile 29.Op Fl t Ar type 30.Ar file 31.Sh DESCRIPTION 32Maps provide a generic interface for associating a textual key to a value. 33Such associations may be accessed through a plaintext file, database, or DNS. 34The format of these file types is described below. 35.Nm 36itself creates the database maps used by keyed map lookups specified in 37.Xr smtpd.conf 5 . 38.Pp 39.Nm 40reads input from 41.Ar file 42and writes data to a file which is named by adding a 43.Dq .db 44suffix to 45.Ar file . 46The current line can be extended over multiple lines using a backslash 47.Pq Sq \e . 48Comments can be put anywhere in the file using a hash mark 49.Pq Sq # , 50and extend to the end of the current line. 51Care should be taken when commenting out multi-line text: 52the comment is effective until the end of the entire block. 53In all cases, 54.Nm 55reads lines consisting of words separated by whitespace. 56The first word of a line is the database key; 57the remainder represents the mapped value. 58The database key and value may optionally be separated 59by the colon character. 60.Pp 61The options are as follows: 62.Bl -tag -width Ds 63.It Fl d Ar dbtype 64Specify the format of the database. 65Available formats are 66.Ar hash 67and 68.Ar btree . 69The default value is 70.Ar hash . 71.It Fl o Ar dbfile 72Write the generated database to 73.Ar dbfile . 74.It Fl t Ar type 75Specify the format of the resulting map file. 76The default map format is suitable for storing simple, unstructured, 77key-to-value string associations. 78However, if the mapped value has special meaning, 79as in the case of a virtual domains file, 80a suitable 81.Ar type 82must be provided. 83The available output types are: 84.Bl -tag -width "aliases" 85.It Cm aliases 86The mapped value is a comma-separated list of mail destinations. 87This format can be used for building user aliases and 88user mappings for virtual domain files. 89.It Cm set 90There is no mapped value \(en a map of this type will only allow for 91the lookup of keys. 92This format can be used for building primary domain maps. 93.El 94.It Fl U 95Instead of generating a database map from text input, 96dump the contents of a database map as text 97with the key and value separated with a tab. 98.El 99.Sh PRIMARY DOMAINS 100Primary domains can be kept in tables. 101To create a primary domain table, add each primary domain on a 102single line by itself. 103.Pp 104In addition to adding an entry to the primary domain map, 105one must add a filter rule that accepts mail for the domain 106map, for example: 107.Bd -literal -offset indent 108table domains db:/etc/mail/domains.db 109 110action "local" mbox 111 112match for domain <domains> action "local" 113.Ed 114.Sh VIRTUAL DOMAINS 115Virtual domains may also be kept in tables. 116To create a virtual domain table, add each virtual domain on a 117single line by itself. 118.Pp 119Virtual domains expect a mapping of virtual users to real users 120in order to determine if a recipient is accepted or not. 121The mapping format is an extension to 122.Xr aliases 5 , 123which allows the use of 124.Dq user@domain.tld 125to accept user only on the specified domain, 126.Dq user 127to accept the user for any of the virtual domains, 128.Dq @domain.tld 129to provide a catch-all for the specified domain and 130.Dq @ 131to provide a global catch-all for all domains. 132.Xr smtpd 8 133will perform the lookups in that specific order. 134.Pp 135To create a single virtual address, add 136.Dq user@example.com user 137to the users map. 138To handle all mail destined to any user at example.com, add 139.Dq @example.com user 140to the virtual map. 141.Pp 142In addition to adding an entry to the virtual map, 143one must add a filter rule that accepts mail for virtual domains, 144for example: 145.Bd -literal -offset indent 146table vdomains db:/etc/mail/vdomains.db 147table vusers db:/etc/mail/users.db 148 149action "local" mbox virtual <vusers> 150 151match for domain <vdomains> action "local" 152match for domain "example.org" action "local" 153.Ed 154.Sh FILES 155.Bl -tag -width "/etc/mail/aliasesXXX" -compact 156.It Pa /etc/mail/aliases 157List of user mail aliases. 158.It Pa /etc/mail/secrets 159List of remote host credentials. 160.El 161.Sh EXIT STATUS 162.Ex -std makemap 163.Sh SEE ALSO 164.Xr aliases 5 , 165.Xr smtpd.conf 5 , 166.Xr table 5 , 167.Xr newaliases 8 , 168.Xr smtpd 8 169.Sh HISTORY 170The 171.Nm 172command first appeared in 173.Ox 4.6 174as a replacement for the equivalent command shipped with sendmail. 175