Bring BSD-licensed ext2fs from FreeBSD
[ikiwiki.git] / docs / handbook / handbook-sendmail.mdwn
1 ## 20.3 sendmail Configuration \r
2 \r
3 ***Contributed by Christopher Shumway. ***\r
4 \r
5 [sendmail(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#sendmail&section8) is the default Mail Transfer Agent (MTA) in DragonFly.  **sendmail** 's job is to accept mail from Mail User Agents (MUA) and deliver it to the appropriate mailer as defined by its configuration file.  **sendmail**  can also accept network connections and deliver mail to local mailboxes or deliver it to another program.\r
6 \r
7  **sendmail**  uses the following configuration files:\r
8 \r
9 [[!table  data="""
10 | Filename | Function 
11  `/etc/mail/access` |  **sendmail**  access database file 
12  `/etc/mail/aliases` | Mailbox aliases 
13  `/etc/mail/local-host-names` | Lists of hosts  **sendmail**  accepts mail for 
14  `/etc/mail/mailer.conf` | Mailer program configuration 
15  `/etc/mail/mailertable` | Mailer delivery table 
16  `/etc/mail/sendmail.cf` |  **sendmail**  master configuration file 
17  `/etc/mail/virtusertable` | Virtual users and domain tables |\r
18 """]]\r
19 ### 20.3.1 `/etc/mail/access` \r
20 \r
21 The access database defines what host(s) or IP addresses have access to the local mail server and what kind of access they have. Hosts can be listed as `OK`, `REJECT`, `RELAY` or simply passed to  **sendmail** 's error handling routine with a given mailer error. Hosts that are listed as `OK`, which is the default, are allowed to send mail to this host as long as the mail's final destination is the local machine. Hosts that are listed as `REJECT` are rejected for all mail connections. Hosts that have the `RELAY` option for their hostname are allowed to send mail for any destination through this mail server.\r
22 \r
23  **Example 20-1. Configuring the** sendmail ** Access Database** \r
24 \r
25     \r
26     cyberspammer.com                550 We don't accept mail from spammers\r
27     FREE.STEALTH.MAILER@            550 We don't accept mail from spammers\r
28     another.source.of.spam          REJECT\r
29     okay.cyberspammer.com           OK\r
30     128.32                          RELAY\r
31 \r
32 \r
33 In this example we have five entries. Mail senders that match the left hand side of the table are affected by the action on the right side of the table. The first two examples give an error code to  **sendmail** 's error handling routine. The message is printed to the remote host when a mail matches the left hand side of the table. The next entry rejects mail from a specific host on the Internet, `another.source.of.spam`. The next entry accepts mail connections from a host `okay.cyberspammer.com`, which is more exact than the `cyberspammer.com` line above. More specific matches override less exact matches. The last entry allows relaying of electronic mail from hosts with an IP address that begins with `128.32`. These hosts would be able to send mail through this mail server that are destined for other mail servers.\r
34 \r
35 When this file is updated, you need to run `make` in `/etc/mail/` to update the database.\r
36 \r
37 ### 20.3.2 `/etc/mail/aliases` \r
38 \r
39 The aliases database contains a list of virtual mailboxes that are expanded to other user(s), files, programs or other aliases. Here are a few examples that can be used in `/etc/mail/aliases`:\r
40 \r
41  **Example 20-2. Mail Aliases** \r
42 \r
43     \r
44     root: localuser\r
45     ftp-bugs: joe,eric,paul\r
46     bit.bucket:  /dev/null\r
47     procmail: "|/usr/local/bin/procmail"\r
48 \r
49 \r
50 The file format is simple; the mailbox name on the left side of the colon is expanded to the target(s) on the right. The first example simply expands the mailbox `root` to the mailbox `localuser`, which is then looked up again in the aliases database. If no match is found, then the message is delivered to the local user `localuser`. The next example shows a mail list. Mail to the mailbox `ftp-bugs` is expanded to the three local mailboxes `joe`, `eric`, and `paul`. Note that a remote mailbox could be specified as `user@example.com`. The next example shows writing mail to a file, in this case `/dev/null`. The last example shows sending mail to a program, in this case the mail message is written to the standard input of `/usr/local/bin/procmail` through a UNIXÃ\82® pipe.\r
51 \r
52 When this file is updated, you need to run `make` in `/etc/mail/` to update the database.\r
53 \r
54 ### 20.3.3 `/etc/mail/local-host-names` \r
55 \r
56 This is a list of hostnames [sendmail(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#sendmail&section8) is to accept as the local host name. Place any domains or hosts that  **sendmail**  is to be receiving mail for. For example, if this mail server was to accept mail for the domain `example.com` and the host `mail.example.com`, its `local-host-names` might look something like this:\r
57 \r
58     \r
59     example.com\r
60     mail.example.com\r
61 \r
62 \r
63 When this file is updated, [sendmail(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#sendmail&section8) needs to be restarted to read the changes.\r
64 \r
65 ### 20.3.4 `/etc/mail/sendmail.cf` \r
66 \r
67  **sendmail** 's master configuration file, `sendmail.cf` controls the overall behavior of  **sendmail** , including everything from rewriting e-mail addresses to printing rejection messages to remote mail servers. Naturally, with such a diverse role, this configuration file is quite complex and its details are a bit out of the scope of this section. Fortunately, this file rarely needs to be changed for standard mail servers.\r
68 \r
69 The master  **sendmail**  configuration file can be built from [m4(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#m4&section1) macros that define the features and behavior of  **sendmail** . Please see `/usr/src/contrib/sendmail/cf/README` for some of the details.\r
70 \r
71 When changes to this file are made,  **sendmail**  needs to be restarted for the changes to take effect.\r
72 \r
73 ### 20.3.5 `/etc/mail/virtusertable` \r
74 \r
75 The `virtusertable` maps mail addresses for virtual domains and mailboxes to real mailboxes. These mailboxes can be local, remote, aliases defined in `/etc/mail/aliases` or files.\r
76 \r
77 ***'Example 20-3. Example Virtual Domain Mail Map***'\r
78 \r
79     \r
80     root@example.com                root\r
81     postmaster@example.com          postmaster@noc.example.net\r
82     @example.com                    joe\r
83 \r
84 \r
85 In the above example, we have a mapping for a domain `example.com`. This file is processed in a first match order down the file. The first item maps `root@example.com` to the local mailbox `root`. The next entry maps `postmaster@example.com` to the mailbox `postmaster` on the host `noc.example.net`. Finally, if nothing from `example.com` has matched so far, it will match the last mapping, which matches every other mail message addressed to someone at `example.com`. This will be mapped to the local mailbox `joe`.\r
86 \r
87 \r
88 \r
89 CategoryHandbook\r
90 Category\r
91 ----\r
92 CategoryCategory CategoryTemplate\r