Typo
[linux_from_scratch_hints.git] / OLD / sendmail.txt
blob16d09f385e230cad815259711fef07fd751b81b0
1 GENERAL OUTLINE
2 ===============
4 TITLE:          Sendmail 8.11
5 LFS VERSION:    Any
6 AUTHOR:         J. Jones <wwbarf@qnexfvqr.qlahc.arg>
8 SYNOPSIS:
9         This hint covers the building, configuring, and use of Sendmail 8.11.  Any
10 and all feedback is welcome.  Rot13 the address.
12 HINT:
14 Software you need
15 =================
17   Sendmail (duh):  ftp://ftp.sendmail.org/pub/sendmail/
18     This hint *only* covers version 8.11.  Grab the latest, which is 8.11.5 at
19     this time.  This hint will *not* work for version 8.12.
21   Procmail:  http://www.procmail.org/
22     This will be used as our local delivery agent.
24   Berkeley DB:  http://www.sleepycat.com/download.html
25     Sendmail uses this (libdb) to store much of it's configuration.
26     Use the latest 3.* version (3.3.11 currently).
28 Building the required packages
29 ==============================
31 Berzerkeley DB:
33   Unpack the source tarball, cd into the build_unix/ subdirectory of the directory
34   created.  From here, run the following:
36     ../dist/configure --prefix=/usr --enable-compat185 \
37       --enable-shared --enable-static
38     make
39     make docdir=/usr/doc/Berkeley-DB install
40     mv /usr/lib/libdb-3.3.a /usr/lib/libdb.a
42     There was apparently a typo in the 3.3.11 package.  The sed below reverts
43     db_185.h to it's last working state.  Sendmail does not use this
44     compatibility, but many other packages do (GNOME).
46     sed 's/^DB185/DB/' /usr/include/db_185.h > /usr/include/db_185.h.new
47     mv /usr/include/db_185.h.new /usr/include/db_185.h
49 Procmail:
51   Unpack the source tarball, cd into the directory it created.  From here, run
52   the following:
54     touch /usr/sbin/sendmail
55     make
56     make install
57     make install-suid
59   Procmail will look for a sendmail file anywhere in the $PATH.  If it doesn't
60   exist, it will prompt you for it.  Touching the file will allow it to find
61   sendmail in the location where we will later install it.
63 Sendmail:
65   Unpack the source tarball, cd into the directory it created.
67   Edit the file devtools/OS/Linux.  At the end of this file, add the following
68   lines:
70     define(`confMANGRP',`root')
71     define(`confMANOWN',`root')
72     define(`confSBINGRP',`root')
73     define(`confUBINGRP',`root')
74     define(`confUBINOWN',`root')
76   You can also define/change the optimization flags here.  By default, we will
77   be building the 'OPTIMIZED' variant, so this is the only one you need to edit.
79   Run the following:
81     cd sendmail/ && sh Build && cd ../
83   Once that has completed (without error, hopefully), we need to build a
84   config file.  The file cf/README has explanations of virtually every
85   sendmail configuration option available.  I would advise you to at least
86   browse the sections the config below mentions.
88   cd into the cf/cf/ directory.  Edit the file config.mc (it doesn't exist..
89   we are creating it).  The following is the config I use, and it has proven
90   itself to be quite flexible.  I am recommending this config for most.  If
91   you feel you may have special needs, consult the cf/README file.
93   The following lines belong in the config.mc file you should be editing now.
95     divert(0)dnl
96     VERSIONID(`$Id: sendmail.txt,v 1.1 2003/09/13 16:18:13 tushar Exp $')
97     OSTYPE(linux)dnl
98     DOMAIN(generic)dnl
99     FEATURE(smrsh)dnl
100     MAILER(local)dnl
101     MAILER(smtp)dnl
102     FEATURE(`nouucp',`reject')dnl
103     FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable')dnl
104     define(`confCW_FILE', `-o /etc/mail/local-domains')dnl
105     FEATURE(`access_db',`hash /etc/mail/access')dnl
106     FEATURE(`no_default_msa')
108   This config enables the following features.
109     * smrsh (sendmail restricted shell).
110     * procmail as the local delivery agent.  (This is default with
111         OSTYPE(linux))
112     * No uucp support.
113     * Virtual user table support.
114     * Access database support (handles relaying, blacklisting, etc).
116   Save this file, and run the following command:
118     sh Build config.cf
119     mkdir -p /etc/mail /var/spool/mqueue /var/lib/smrsh
120     cp config.cf /etc/mail/sendmail.cf
121     cp config.mc /etc/mail/
123   If there were any errors generating the config.cf file, please double check
124   the config.mc's syntax (check those `' things).
126   We are going to change smrsh's bin directory from /var/adm/sm.bin to
127   /var/lib/smrsh, because the default doesn't seem very appropriate to me,
128   and it's not very FHS compliant.  Enter the sendmail-root/smrsh/ directory
129   (should be a cd ../../smrsh/ away), and run the following commands:
131     sed 's|\(.*var/\)adm/sm.bin\(.*$\)|\1lib/smrsh\2|' smrsh.c > new-smrsh.c
132     mv new-smrsh.c smrsh.c
134   Now, enter the top source directory (should be a cd ../ away), and run
135   the following:
137     sh Build
138     sh Build install
140   Sendmail is now installed.
142   The sendmail restricted shell is what will be executed (in place of /bin/sh)
143   in order to process any commands that may appear in a user's .forward file.
144   It can only execute a program if it appears in it's command directory.  From
145   the /var/lib/smrsh directory, execute the following:
147     ln -s /usr/bin/procmail
148     ln -s /usr/bin/vacation
150   This will allow smrsh to execute procmail and vacation, and nothing else.
151   You should never allow it to execute any shell, as it will defeat any
152   security advantages gained by using it.
154   Edit the /etc/mail/aliases file.  Insert (at least) the following lines:
156     postmaster: root
157     MAILER-DAEMON: root
159   See man 5 aliases for an explanation of this file.  It is fairly
160   straight-forward.
162   Edit the /etc/mail/access file.  This file only has to exist.. null content
163   is OK.  This file is quite powerful.. you should read the cf/README section
164   about it to fully understand it.
166   These lines are to serve as an example, and are not required in any way.
168     10.0.0 RELAY
169     spammer@aol.com ERROR:"550 spam sucks"
171   The first line tells sendmail to relay any request from my LAN, 10.0.0.*.
172   The second line tells sendmail to reject any mail from spammer@aol.com with
173   the message, "spam sucks".
175   IMPORTANT:  The following command MUST BE EXECUTED after ANY changes to the
176               /etc/mail/access file.
178   Now, we must create the access.db (in the form sendmail wants it).  The
179   following command will do so.
181     makemap hash /etc/mail/access < /etc/mail/access
183   This is the last step in the sendmail configuration.  We will create the
184   local-domains file, which sendmail uses as a list of domains which will be
185   treated as 'local'.  If I wanted to accept mail for @microsoft.com, I would
186   insert, on one line, microsoft.com.  Here's my sample local-domains file.
188     darkside.dynup.net
189     crypt.dynup.net
191   Finally, run the following command:
193     sendmail -v -bi
195   This command tells sendmail to build it's alias database.  The -v tells it
196   to be very verbose about any possible permission and/or configuration issues
197   that may exist.  If it's output is more than something like:
199     /etc/mail/aliases: 5 aliases, longest 6 bytes, 62 bytes total
201   you should attempt to correct the error (these are usually filesystem
202   permission issues).  Check sendmail's output into syslog, too.
204   Sendmail provides the newaliases command which you should use from now on to
205   update your aliases.
207 Running sendmail
208 ================
210   To run sendmail in daemon mode, where it will listen on port 25 and accept
211   mail, use the following.
213     /usr/sbin/sendmail -bd -q20m
215   The -q20m tells sendmail to re-run the mail queue every 20 minutes.
217   To stop sendmail, use the following:
219     kill -SIGTERM `head -1 /var/run/sendmail.pid`
221   Sendmail provides a few useful tools:
223     mailq:
224       Dumps the contents of the mail spool, along with the status of
225       each message.
227     mailstats:
228       Shows various usage stats.
230     praliases:
231       Displays current aliases.
233     vacation:
234       Auto-responder of sorts for when you're laying on the beach.
236   See the corresponding man pages for more information.
238 Testing your configuration
239 ==========================
241   The easiest way will be to open an MUA (like mutt), and first attempt to
242   send a message to "root".  If root recieves the message, things should be
243   ok.  Second, send a message to root@some.host.you.listed.in./etc/sendmail.cw.
244   Do this for each domain you have listed in that file.  All mail should go to
245   root.
247   There are some more 'advanced' features that are beyond the scope of this.
248   You should refer to the excellent documentation which comes with the sendmail
249   source and the FAQ located at www.sendmail.org for more information.
251 Common Problems / FAQ
252 =====================
254   Q:  Sendmail takes forever to start! WTF!
256   A:  Sendmail can't resolve your hostname.  In /etc/hosts, you need the
257       following:
259         127.0.0.1 hostname.domain.tld hostname
261   Q:  The hostname and domain sendmail picks up isn't the right one!  Any mail
262       I send comes from an unresolvable/incorrect domain!
264   A:  Add the following lines to /etc/mail/sendmail.cf
266         Dwmyhostname
267         Dmmydomain.tld
268         Dj$w.$m
270       The Dw<string> defines the hostname, Dm<string> defines the subdomain
271       name, and the Dj line expands the Dw and the Dm values into the
272       canonical domain name, which is myhostname.mydomain.tld in the above
273       example.
275       The above will force sendmail to act as that host.domain.tld.
276       Alternatively, you could simply:
278         DMhostname.domain.tld
280       which would tell sendmail to 'masquerade' all mail as
281       hostname.domain.tld.
283       Either of these will fix the issue, but the previous is probably the
284       one you will want to go with.  With the latter, sendmail will still
285       identify itself as the erroneous host.domain.tld.
287   Q:  Mutt (the *ONLY* MUA!) errors out when I try to send a message!
288       Something about an exec error 127!  WTF!
290   A:  Add the following line to either 1) your ~/.muttrc, or 2) the
291       system-wide Muttrc (mutt's ./configure --prefix/etc/Muttrc).
292       The latter is the more sensible of the two.
294         set sendmail = "/usr/sbin/sendmail"
296       Restart mutt.
298   Q:  Sendmail complains about some files in group writable directories, and
299       refuses to use them!
301   A:  If you are *absolutely* certain you know what you're doing, make the
302       following changes to your /etc/mail/sendmail.cf.  Otherwise, fix the
303       directory permissions.
305       You need to add the following options to the DontBlameSendmail option in
306       your /etc/mail/sendmail.cf.
307         GroupWritableDirPathSafe
308         GroupWritableForwardFileSafe
309         ForwardFileInGroupWritableDirPath
310         GroupWritableAliasFile
312       The format of that line should be something resembling this:
313         O DontBlameSendmail=option1,option2,option3
315       See http://www.sendmail.org/tips/DontBlameSendmail.html for more info.
318   Q:  I want to use Maildir damnit!
320   A:  Edit your ~/.procmailrc, insert the following:
322         :0
323         *
324         /home/your_username/Mail/
326       Run:  mkdir -p ~/Mail/{cur,new,tmp}
328       Voila.  Your mail will now be delivered to ~/Mail/, in the maildir format.
330 ===========
331 End of hint