General search: AltaVista * DejaNews * Infoseek * Lycos * Open Text * Excite * Yahoo
Specific search: Desk Reference * Domain/Host Lookup * People * Software

How to Set Up Sendmail for Debian Linux


Setting Up Sendmail

These instructions assume you get my mail from an Internet Service Provider, by using POP to download mail, and SMTP to upload it.

Overview:

  1. Customize the sendmail macros file which best matches your configuration. Replace mail.local with procmail in the ostype file for debian.m4; also, set the flags properly. Replace mail.local with procmail in the mailer file for local.m4; also, set the flags properly.
  2. Expand the macros in your macro file to produce a trial configuration file.
  3. Test the configuration file.
  4. Install the configuration file as sendmail.cf.
  5. Construct a local aliases file.
  6. Compile the aliases file into database format.
  7. Test that you can retrieve mail.
  8. Set up your delivery agent; these instructions currently apply only to MH.
  9. Start the sendmail daemon.
  10. Edit your boot script, to insure the sendmail is invoked automatically when you log on.

  1. Customizing the Sendmail Macros

    The version of sendmail shipped with Debian Linux is meant to be configured using the the sendmail+IDA system, which lets you build sendmail.cf by means of simple (m4-based) macro files. The macro files you need for input are in various subdirectories of /usr/src/sendmail.cf.

    Build a custom file in the cf sub-directory.
    • Edit /usr/src/sendmail.cf/cf/[whatever's closest to what you want]. Inspect the files that are already there, and choose the one that's "closest" to the configuration you want. In my case, (single machine obtaining mail via a POP connection from an ISP), that file is /usr/src/sendmail.cf/cf/deb-local.mc. I copied this file to another which I called deb-local.mc.debian, then added these lines:
            FEATURE(nouucp)dnl
            MAILER(smtp)dnl
            define(`ALIAS_FILE', /usr/local/etc/aliases)dnl
      
      The first line merely says not to process any uucp mail. The second line makes smtp available for managing outgoing mail. The third line specifies the location of the alias file.
    • Edit /usr/src/sendmail.cf/mailer/local.m4. Again, copy local.m4 to local.m4.debian, then change LOCAL_MAILER_FLAGS from `rmn' to `rmnS'. Change LOCAL_MAILER_PATH from /bin/mail to /usr/bin/procmail.
    • Edit /usr/src/sendmail.cf/ostype/debian.m4. Once again, copy debian.m4 to debian.m4.debian, then change the LOCAL_MAILER_PATH from /usr/sbin/mail.local to /usr/bin/mail.


  2. Expand the Sendmail Macros

    Return to the /usr/src/sendmail/cf directory and make a deb-local.cf file from your deb-local.mc file. To do this, execute:

        make deb-local.cf
    
    Note that even though the file you wrote is deb-local.mc, the argument you give to the make command is deb-local.cf. (That will be the output that you're making.) That places a file called deb-local.cf in the sub-directory `obj' of the current directory. It's ready for testing.
  3. Test the Trial Sendmail Configuration File

    Test the .cf file you just made. To do this, try mailing a junk file to root. Let's imagine your current directory is /usr/src/sendmail.cf/cf. Then execute this to see if you can get mail as user root:

    /usr/sbin/sendmail -v -Cobj/deb-local.cf root < deb-local.mc
    
    You should get a message that says
    Sent
    
    You can check that by using the command
    mail
    
    You should then see the file deb-local.mc sent to you as a mail message. Try mailing to anyone else, using the same command, or use
    mail -v person < filename
    
    Here's a test of your configuration file's ability to do address resolution correctly:
    /usr/sbin/sendmail -vt -Cobj/deb-local.cf
    
    You will get the following message:
    ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
    Enter  
    Enter <ruleset> <address>
    followed by a prompt at which you should enter rule set numbers followed by an address you'd like to see resolved:
    > 0 sgk
    
    This returns:
    rewrite: ruleset  0   input: sgk
    rewrite: ruleset 98   input: sgk
    rewrite: ruleset 98 returns: sgk
    rewrite: ruleset  0 returns: $# local $: sgk
    
    If you'd like to see your From address being built up while sendmail is working, you can use this:
     /usr/sbin/sendmail -v -d0.4 -Cobj/deb-local.cf someuser < somefile
    
    If you'd like to see your macros expanded, use:
     /usr/sbin/sendmail -v -d37.2 -Cobj/deb-local.cf someuser < somefile
    


  4. Installing the Configuration File

    Install your newly minted configuration file as the official sendmail configuration file:

        cp /usr/src/sendmail/cf/obj/deb-local.cf /etc/sendmail.cf
    
    [What must the permissions and owner be?]


  5. Set up an Aliases File

    Create a file called aliases in whatever directory you specified in your deb-local.mc file. In my case (see above), it would be /usr/local/etc/aliases. This file should include all your 'system' aliases; it should have at least these two lines:

       postmaster:    mail
       mailer-daemon: postmaster
       

  6. Compile the Aliases File into Database Format

    Sendmail uses a compact database form of the aliases file, rather than the ASCII file itself. To convert the ASCII file you've just made into database form, use:

    /usr/sbin/sendmail -bi 
    
    This uses the file specified as the ALIASES in your deb-local.mc file to *initialize* (note the -i flag) a new aliases database, i.e., put it in 'dbm' format.
  7. Test that You can Retrieve Mail

    If you retrieve mail via POP from your provider, you can use this command to download mail.

        popclient -3 -k -u yourusername -p password FQDN
    
    where you should replace -- 'username' with the user name of your account at your ISP,
    -- 'password' with the password of your account at your ISP, and
    -- 'FQDN' with the fully qualified domain name of the host that provides you with mail. For example, in my case it is zork.tiac.net

    The -k tells popclient to keep the files at the server, i.e., don't erase them. This is a BIG help if your mail setup is less than perfect. If you don't use this, some of your mail could go to never-never land.


  8. Set Up Your Mail User Agent

    Some of the more popular mail user agents are the venerable 'mail' program, pine, elm, and MH. These instructions apply to MH. (To be expanded to included other MUA's later.)

    Customize /etc/mh/mtstailor.
    Add these lines to it:
           localname:      sgk.tiac.net
           clientname:     sgk.tiac.net
           pophost:        remote_fqdn
           servers:        sgk.tiac.net remote_fqdn
    
    In the above, replace local_fqdn with the name of your local host. Also, replace remote_fqdn with the fully-qualified domain name of the host that gets your mail. In my case, that's zork.tiac.net
    Construct a file called '.netrc'.
    Enter the lines that will provide access to your user accounts at the remote_fqdn and sgk.tiac.net. In my case, those lines are:
           machine 'remote_fqdn' login 'username' password 'password'
           machine sgk.tiac.net     login 'username' password 'password'
    
    where the terms in quotes should be replaced by the appropriate values (without quotes).
    Fix the permissions on .netrc
    For a user named joe, you would execute:
           chmod 600 ~joe/.netrc
    
    Customize .mh_profile.
    In my case, I added these lines:
          inc:  -noaudit -norpop -noapop 
          showproc:  more
    
    (The Debian compiled version of showproc incorrectly specifies '/usr/bin/more' rather than '/bin/more' as the showproc, and this is a fix to that.)

  9. Initiate the Sendmail Daemon

    You can start the sendmail daemon from the command line by executing a command like:

    /usr/sbin/sendmail -bd -q10m -i
    
    • The -bd flag does XXX.
    • The -q10m flag does XXX.
    • The -i flag to sendmail tells it to ignore leading '.' in messages. This is a good thing to do, because some mailers interpret a leading dot in such a way that they wind up sending duplicate messages.

  10. Edit Your Boot Scripts

    So that you won't have to start the sendmail daemon by hand every time you boot the computer, edit your boot scripts to do the initiation for you. Either construct a file called /etc/rc.boot/sendmail with this line:

        /usr/sbin/sendmail -bd -2m
    
    or construct a file called /etc/init.d/sendmail with the same line:

Back to: Tuning Linux: Table of Contents


S. G. Kleinmann(sgk@sgk.phast.umass.edu).Last modified on Sun Aug 11 21:24:17 1996

Go Home or to: Computing * Communications * Government * Physical Sciences * Job$ and Inve$ting * Leisure