Linux E-mail

Book description

Set up, maintain, and secure a small office email server

  • Covers all the information you need to easily set up your own Linux email server
  • Learn how to provide web access to email, virus and spam protection, and more
  • Thoroughly covers open source tools like PostFix, Courier, SpamAssassin, and ProcMail
  • A step-by-step approach where the reader is taken through examples with ample screenshots and clear explanations to facilitate learning

In Detail

Many businesses want to run their email servers on Linux for greater control and flexibility of corporate communications, but getting started can be complicated. The attractiveness of a free-to-use and robust email service running on Linux can be undermined by the apparent technical challenges involved. Some of the complexity arises from the fact that an email server consists of several components that must be installed and configured separately, then integrated together.

This book gives you just what you need to know to set up and maintain an email server. Unlike other approaches that deal with one component at a time, this book delivers a step-by-step approach across all the server components, leaving you with a complete working email server for your small business network.

Starting with a discussion on why you should even consider hosting your own email server, the book covers setting up the mail server. We then move on to look at providing web access, so that users can access their email out of the office. After this we look at the features you'll want to add to improve email productivity: virus protection, spam detection, and automatic email processing. Finally we look at an essential maintenance task: backups.

Written by professional Linux administrators, the book is aimed at technically confident users and new and part-time system administrators. The emphasis is on simple, practical and reliable guidance.

Based entirely on free, Open Source software, this book will show you how to set up and manage your email server easily.

Table of contents

  1. Linux E-mail
    1. Table of Contents
    2. Linux E-mail
    3. Credits
    4. About the Authors
    5. About the Reviewers
    6. Preface
      1. What this book covers
      2. Who this book is for
      3. Conventions
      4. Reader feedback
      5. Customer support
        1. Errata
        2. Piracy
        3. Questions
    7. 1. Linux and E-mail Basics
      1. Why manage your own e-mail server
      2. What you need to host an e-mail server
      3. Sizing the hardware of your e-mail server
      4. Main e-mail protocols: SMTP, POP, and IMAP
        1. Overview
        2. POP protocol
        3. IMAP protocol
        4. The SMTP protocol
      5. E-mail and DNS
        1. DNS record types used by e-mail applications
      6. Backup mail servers
      7. Summary
    8. 2. Setting up Postfix
      1. Introduction to Postfix
        1. What is Postfix
        2. Postfix architecture: An overview
          1. New message arrival
          2. Scheduling message deliveries
          3. Message delivery
          4. Supporting programs
      2. Installation and basic configuration
        1. Choosing the Postfix version
        2. Installing from a package
        3. Installing from source code
        4. The Postfix configuration
          1. main.cf
          2. master.cf
          3. Lookup tables
        5. Getting Postfix up and running
          1. Domains and hostnames
          2. Indirect mail delivery through your ISP
          3. Choosing network interfaces
          4. Choosing mailbox format for local deliveries
          5. Error reporting
          6. Other useful configuration parameters
          7. Starting Postfix and sending the first message
      3. Stopping spam and other unwanted messages
        1. Postfix's anti-spam methods: An overview
        2. Understanding SMTP restrictions
          1. Access maps
          2. Access map examples
          3. Implementing new policies
        3. Using DNS blacklists
          1. Choosing DNS blacklists
        4. Stopping messages based on content
          1. Configuring header and body checks
          2. Header and body checks examples
          3. Caveats
      4. Virtual alias domains and local aliases
        1. Virtual alias domains
          1. Many virtual alias domains mapping to one local domain
          2. One virtual alias domain mapping to many local domains
          3. Group addresses
          4. Introducing MySQL lookups
        2. Local aliases
          1. Command deliveries
        3. Common pitfalls
        4. Other address rewriting mechanisms
      5. Troubleshooting Postfix problems
        1. Reading and interpreting the log files
          1. Message queue ID
          2. SMTP submission and local delivery
          3. Local submission and SMTP delivery
          4. Connection problems upon SMTP delivery
          5. Getting more detailed log messages
        2. Troubleshooting lookup tables with Postmap
        3. Getting help from the Postfix mailing list
      6. Summary
    9. 3. Incoming Mail with POP and IMAP
      1. Choosing between POP and IMAP
      2. Downloading and installing Courier-IMAP
        1. Installing Courier-IMAP from a distribution repository
        2. Installing Courier-IMAP from RPM
        3. Installing Courier-IMAP using the Debian package format
        4. Installing Courier-IMAP from source
          1. Prerequisites
          2. Building the Courier Authentication Library
          3. Configuring the Courier Authentication Library
          4. Resolving errors
        5. Building Courier-IMAP
          1. Handling errors
      3. Using POP3
        1. Configuring Courier-IMAP for POP3
        2. Testing the POP3 Service
        3. Retrieving E-mail via POP3 with Windows Live Mail
      4. Using IMAP
        1. Configuring Courier for IMAP
        2. Testing the IMAP service
        3. Retrieving mail via IMAP with Mozilla Thunderbird
      5. Summary
    10. 4. Providing Webmail Access
      1. The webmail solution
        1. The benefits
          1. Easy and quick access
          2. Easy remote access
          3. No need to maintain clients
          4. Configuring mail server interface via the user interface
          5. Possible security benefits
        2. The disadvantages
          1. Performance
          2. Compatibility with large e-mail volumes
          3. Compatibility with e-mail attachments
          4. Security issues
      2. The SquirrelMail webmail package
      3. SquirrelMail installation and configuration
        1. Prerequisites to installation
          1. Basic requirements
            1. Installing Apache2
            2. PHP
          2. Perl
          3. Review configuration
        2. Installing SquirrelMail
          1. Source installation
        3. Configuring SquirrelMail
      4. SquirrelMail plugins
        1. Installing plugins
        2. Example plugin installation
          1. Downloading and unpacking the plugin
          2. Performing custom installation
          3. Enabling the plugin in conf.pl
        3. Useful plugins
      5. Securing SquirrelMail
      6. Summary
    11. 5. Securing Your Installation
      1. Configuring Postfix network maps
        1. SMTP-after-POP
        2. Virtual Private Networks
        3. SMTP Authentication
        4. Static IP ranges
          1. Generic relay rules
          2. Explicit relay rules
        5. Dynamic IP ranges
      2. Cyrus SASL
        1. SASL layers
          1. Authentication interface
          2. Mechanism
          3. Method
          4. Password verification service
        2. Installing Cyrus SASL
        3. Configuring Cyrus SASL
          1. Selecting a password verification service
          2. Choosing a log level
          3. Choosing valid mechanisms
            1. saslauthd
              1. Using an IMAP server as authentication backend
              2. Using an LDAP server as authentication backend
              3. Using the local user accounts
              4. Using PAM
            2. auxprop
              1. Configuring the sasldb plugin
              2. Configuring the sql plugin
            3. authdaemond
              1. Setting the authdaemond password verification service
              2. Configuring the authdaemond socket path
      3. Testing Cyrus SASL authentication
      4. Configuring Postfix SMTP AUTH
        1. Preparing the configuration
        2. Enabling SMTP AUTH
        3. Setting the security policy
        4. Including broken clients
      5. Testing SMTP AUTH
      6. Enabling relaying for authenticated clients
      7. Securing plaintext mechanisms
        1. Enabling Transport Layer Security
        2. Configuring security policy
      8. Dictionary attacks
        1. Recipient maps
          1. Checking local domain recipients
          2. Checking relay domain recipients
        2. Rate-limiting connections
      9. Summary
    12. 6. Getting Started with Procmail
      1. Introduction to Procmail
        1. Who wrote it and when
      2. How can a filtering system help me?
        1. Potential uses of mail filtering
          1. Filtering and sorting mail
          2. Forwarding mail
          3. Processing the mail in an application
          4. Acknowledgements and out of office/vacation replies
        2. File locking and integrity
        3. What Procmail is not suitable for
      3. Downloading and installing Procmail
        1. Installing via a package manager
        2. Installing from source
        3. Installation options/considerations
          1. Individual installation
          2. System-wide installation
        4. Integration with Postfix for system-wide delivery
          1. Creating an alias for system accounts
          2. Adding Procmail to the Postfix configuration
          3. Postfix-provided environment variables
      4. Basic operations
        1. Configuration file
          1. File format
          2. Configuration file dissection
      5. Analyzing a simple rule
        1. The rule structure
          1. Variable analysis
          2. Rule analysis
      6. Creating and testing a rule
        1. A "hello world" example
        2. Creating rc.testing
        3. Performing static testing of the script
        4. Configuring Procmail to process rc.testing
        5. Testing the setup
      7. Configuration debugging
        1. Checking for typos in the scripts
        2. Looking at the log file for error messages
        3. Checking file and directory permissions
        4. Turning on Full Logging
        5. Taking steps to avoid disasters
      8. Understanding e-mail structure
        1. Message body
        2. E-mail headers
        3. Header structure
        4. Official definitions for headers
      9. Example rule sets
        1. From header
        2. Return-Path Header
          1. Filtering by Return-Path
        3. To and Cc headers
          1. Filtering by To or Cc
        4. Subject header
          1. Filtering by subject
      10. System-wide rules
        1. Removing executables
        2. Large e-mails
      11. Summary
    13. 7. Advanced Procmail
      1. Delivering and non-delivering recipes
        1. Non-delivering example
      2. Formail
      3. Advanced recipe analysis
        1. Adding comments
        2. Assigning variables
          1. Performing substitutions
            1. Assigning variable with default values
            2. Assigning command output to variables
          2. Pseudo-variables
            1. Mailbox variables
            2. Program variables
            3. System interaction variables
            4. Logging variables
            5. Procmail's state variables
            6. Message content variables
            7. Locking variables
            8. Error-handling variables
            9. Miscellaneous variables
            10. Printing Procmail variables
        3. Recipes
          1. Colon line
            1. Locking
              1. Automatic locking
              2. Enforced locking
              3. No locking
            2. Flags
              1. Default flags
              2. Scope of matching: HB
              3. Scope of action: hb
              4. Flow control: aAeEc
              5. Case sensitivity: D
              6. Execution mode: fwWir
          2. Conditions
            1. Applying a rule unconditionally
            2. Tests with regular expressions
            3. Testing the size of a message part
            4. Testing the exit code of an external program
            5. Negation
            6. Variable substitution in conditions
          3. Action line
            1. Forwarding to other addresses
            2. Feeding to a shell or command pipeline
            3. Saving to a folder
            4. Compound recipes
      4. Regular expressions
        1. Introduction to regular expressions
          1. The dot
          2. Quantifier operation
          3. The asterisk
          4. The plus sign
          5. Restrictive matches using parentheses
          6. Creating a simple spam filter
          7. Character classes
          8. Start of line
          9. End of Line
        2. Further reading
        3. ^TO and ^TO_
        4. ^FROM_MAILER
        5. ^FROM_DAEMON
      5. Advanced recipes
        1. Creating a vacation auto reply
        2. Organizing mail by date
        3. Informing users about large mail
      6. Procmail Module Library
      7. Putting it all together
        1. Creating a structure to base your own rules upon
          1. Rc.system
          2. Rc.lists
          3. Rc.killspam
          4. Rc.vacation
          5. Rc.largefiles
          6. Rc.viruses
          7. Rc.spamfilter
      8. Summary
    14. 8. Busting Spam with SpamAssassin
      1. Why filter e-mail
        1. Spam is a moving target
        2. Spam filtering options
      2. Introduction to SpamAssassin
      3. Downloading and installing SpamAssassin
        1. Using CPAN
          1. Configuring CPAN
        2. Installing SpamAssassin using CPAN
        3. Using the rpmbuild utility
        4. Using pre-built RPMs
        5. Testing the installation
          1. Modified e-mails
      4. Using SpamAssassin
        1. Using SpamAssassin with Procmail
          1. Global procmailrc file
          2. Using SpamAssassin on a per-user basis
        2. Using SpamAssassin as a daemon with Postfix
        3. Using SpamAssassin with amavisd-new
          1. Installing amavisd-new from package
          2. Installation prerequisites
          3. Installing from source
          4. Creating a user account for amavisd-new
          5. Configuring amavisd-new
          6. Configuring Postfix to run amavisd-new
      5. Configuring e-mail clients
        1. Microsoft Outlook
        2. Microsoft Outlook Express
        3. Mozilla Thunderbird
      6. Customizing SpamAssassin
        1. Reasons to customize
        2. Rules and scores
        3. Altering rule scores
        4. Using other rulesets
        5. Whitelists and blacklists
        6. Bayesian filtering
      7. Other SpamAssassin features
      8. Summary
    15. 9. Antivirus Protection
      1. Introduction to ClamAV
      2. Document types supported
      3. Downloading and installing ClamAV
        1. Adding a new system user and group
        2. Installing from a package
        3. Installing from source code
          1. Requirements
          2. Building and installing
          3. Quick test
      4. Editing the config files
        1. clamd
          1. Examining the sample config file
        2. freshclam
          1. Closest mirrors
          2. Examining the sample config file
        3. File permissions
      5. Post installation testing
        1. EICAR test virus
        2. Testing clamscan
        3. Testing clamd
        4. Testing freshclam
      6. Introduction to ClamSMTP
        1. Building and installing
        2. Configuring into Postfix
        3. Configuring clamSMTP
          1. Examining the sample config file
      7. Testing e-mail filtering
        1. Testing mail-borne virus filtering
        2. Thorough e-mail-borne testing
      8. Automating update of virus data
        1. Setting up auto updating
      9. Automating startup and shutdown
        1. ClamSMTP
        2. ClamAV
      10. Monitoring log files
      11. Disinfecting files
      12. Summary
    16. 10. Backing Up Your System
      1. Backup options
        1. RAID
        2. Image backups
        3. File system backups
        4. Ad hoc backups
      2. What to back up
        1. System inventory
        2. Obtaining a list of installed software
        3. System configuration files
        4. Authentication data
        5. The users' mailboxes
        6. Log files
        7. The mail queue
      3. What not to back up
      4. Backing up users' e-mail
        1. Mail storage
        2. Using dump
          1. Full dump
          2. Incremental dumps
        3. Using restore
          1. Interactive restore
          2. Non-interactive restore across the network
      5. Backing up configurations and logs
        1. Transferring configurations and logs to backup media
        2. Restoring the configuration
      6. Automating backups
        1. Backup script
        2. Adding crontab entries
      7. Verifying restoration procedures
      8. Summary
    17. Index

Product information

  • Title: Linux E-mail
  • Author(s): Alistair McDonald, Carl Taylor, David Rusenko, Ian Haycox, Magnus Back, Patrick Ben Koetter, Ralf Hildebrandt
  • Release date: November 2009
  • Publisher(s): Packt Publishing
  • ISBN: 9781847198648