1.\" $OpenBSD: makemap.8,v 1.29 2016/02/13 08:53:18 gilles 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 2016 $ 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 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 whose name is made 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 the 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 "/etc/mail/domains" 109accept for domain <domains> deliver to mbox 110.Ed 111.Sh VIRTUAL DOMAINS 112Virtual domains may also be kept in tables. 113To create a virtual domain table, add each virtual domain on a 114single line by itself. 115.Pp 116Virtual domains expect a mapping of virtual users to real users 117in order to determine if a recipient is accepted or not. 118The mapping format is an extension to 119.Xr aliases 5 , 120which allows the use of 121.Dq user@domain.tld 122to accept user only on the specified domain, 123.Dq user 124to accept the user for any of the virtual domains, 125.Dq @domain.tld 126to provide a catch-all for the specified domain and 127.Dq @ 128to provide a global catch-all for all domains. 129.Xr smtpd 8 130will perform the lookups in that specific order. 131.Pp 132To create single virtual address, add 133.Dq user@example.com user 134to the users map. 135To handle all mail destined to any user at example.com, add 136.Dq @example.com user 137to the virtual map. 138.Pp 139In addition to adding an entry to the virtual map, 140one must add a filter rule that accepts mail for virtual domains, 141for example: 142.Bd -literal -offset indent 143table vdomains "/etc/mail/vdomains" 144table vusers "/etc/mail/users" 145 146accept for domain <vdomains> virtual <vusers> deliver to mbox 147accept for domain example.org virtual <vusers> deliver to mbox 148.Ed 149.Sh FILES 150.Bl -tag -width "/etc/mail/aliasesXXX" -compact 151.It Pa /etc/mail/aliases 152List of user mail aliases. 153.It Pa /etc/mail/secrets 154List of remote host credentials. 155.El 156.Sh EXIT STATUS 157.Ex -std makemap 158.Sh SEE ALSO 159.Xr aliases 5 , 160.Xr smtpd.conf 5 , 161.Xr table 5 , 162.Xr newaliases 8 , 163.Xr smtpd 8 164.Sh HISTORY 165The 166.Nm 167command first appeared in 168.Ox 4.6 169as a replacement for the equivalent command shipped with sendmail. 170