Matt Simerson > Mail-Toaster-5.13 > Mail::Toaster

Download:
Mail-Toaster-5.13.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 5.13   Source   Latest Release: Mail-Toaster-5.49

NAME ^

Mail::Toaster - turns a computer into a secure, full-featured, high-performance mail server.

VERSION ^

5.13

SYNOPSIS ^

    functions used in: toaster-watcher.pl
                       toaster_setup.pl
                       qqtool.pl

To expose much of what can be done with these, run toaster_setup.pl -s help and you'll get a list of the available targets.

The functions in Mail::Toaster.pm are used by toaster-watcher.pl (which is run every 5 minutes via cron), as well as in toaster_setup.pl and other functions, particularly those in Qmail.pm and mailadmin.

USAGE ^

    use Mail::Toaster;
    my $toaster = Mail::Toaster->new;
    
    # verify that processes are all running and complain if not
    $toaster->toaster_check();

    # get a list of all maildirs on the system
    my @all_maildirs = $toaster->get_maildir_paths();
    
    # clean up old messages over X days old
    $toaster->clean_mailboxes();
    
    # clean up messages in Trash folders that exceed X days
    foreach my $maildir ( @all_maildirs ) {
        $toaster->maildir_clean_trash( path => $maildir );
    };

These functions can all be called indivually, see the working examples in the aforementioned scripts or the t/Toaster.t file.

DESCRIPTION ^

Mail::Toaster, Everything you need to build a industrial strength mail system.

A collection of perl scripts and modules that are quite useful for building and maintaining a mail system. It was first authored for FreeBSD and has since been extended to Mac OS X, and Linux. It has become quite useful on other platforms and may grow to support other MTA's (think postfix) in the future.

SUBROUTINES ^

A separate section listing the public components of the module's interface. These normally consist of either subroutines that may be exported, or methods that may be called on objects belonging to the classes that the module provides. Name the section accordingly.

In an object-oriented module, this section should begin with a sentence of the form "An object of this class represents...", to give the reader a high-level context to help them understand the methods that are subsequently described.

new
  ############################################
  # Usage      : use Mail::Toaster;
  #            : my $toaster = Mail::Toaster->new;
  # Purpose    : create a new Mail::Toaster object
  # Returns    : an object to access Mail::Toaster functions
  # Parameters : none
  # Throws     : no exceptions
toaster_check
  ############################################
  # Usage      : $toaster->toaster_check();
  # Purpose    : Runs a series of tests to inform admins of server problems
  # Returns    : prints out a series of test failures
  # Throws     : no exceptions
  # See Also   : toaster-watcher.pl
  # Comments   : 

Performs the following tests:

   • check for processes that should be running.
   • make sure watcher.log is less than 1MB
   • make sure ~alias/.qmail-* exist and are not empty
   • verify multilog log directories are working

When this is run by toaster-watcher.pl via cron, the mail server admin will get notified via email any time one of the tests fails. Otherwise, there is no output generated.

learn_mailboxes
  ############################################
  # Usage      : $toaster->learn_mailboxes();
  # Purpose    : train SpamAssassin bayesian filters with your ham & spam
  # Returns    : 0 - failure, 1 - success
  # See Also   : n/a
  # Comments   : 

Powers an easy to use mechanism for training SpamAssassin on what you think is ham versus spam. It does this by trawling through a mail system, finding mail messages that have arrived since the last time it ran. It passes these messages through sa-learn with the appropriate flags (sa-learn --ham|--spam) to train its bayesian filters.

clean_mailboxes
  ############# clean_mailboxes ##############
  # Usage      : $toaster->clean_mailboxes();
  # Purpose    : cleaning out old mail messages from user mailboxes
  # Returns    : 0 - failure, 1 - success
  # See Also   : n/a
  # Comments   :

This sub trawls through the mail system pruning all messages that exceed the threshholds defined in toaster-watcher.conf.

Peter Brezny suggests adding another option which is good. Set a window during which the cleaning script can run so that it is not running during the highest load times.

email_send
  ############ email_send ####################
  # Usage      : $toaster->email_send(type=>"clean" );
  #            : $toaster->email_send(type=>"spam"  );
  #            : $toaster->email_send(type=>"attach");
  #            : $toaster->email_send(type=>"virus" );
  #            : $toaster->email_send(type=>"clam"  );
  #
  # Purpose    : send test emails to test the content scanner
  # Returns    : 1 on success
  # Parameters : type (clean, spam, attach, virus, clam)
  # See Also   : email_send_[clean|spam|...]

Email test routines for testing a mail toaster installation.

This sends a test email of a specified type to the postmaster email address configured in toaster-watcher.conf.

email_send_attach
  ######### email_send_attach ###############
  # Usage      : internal only
  # Purpose    : send an email with a .com attachment
  # Parameters : an email address
  # See Also   : email_send

Sends a sample test email to the provided address with a .com file extension. If attachment scanning is enabled, this should trigger the content scanner (simscan/qmailscanner/etc) to reject the message.

email_send_clam

Sends a test clam.zip test virus pattern, testing to verify that the AV engine catches it.

email_send_clean

Sends a test clean email that the email filters should not block.

email_send_eicar

Sends an email message with the Eicar virus inline. It should trigger the AV engine and block the message.

email_send_spam

Sends a sample spam message that SpamAssassin should block.

get_toaster_cgibin

Determine the location of the cgi-bin directory used for email applications.

get_toaster_conf

Determine where the *.conf files for mail-toaster are stored.

get_toaster_logs

Determine where log files are stored.

get_toaster_htdocs

Determine the location of the htdocs directory used for email applications.

maildir_clean_spam
  ########### maildir_clean_spam #############
  # Usage      : $toaster->maildir_clean_spam( 
  #                  path => '/home/domains/example.com/user',
  #              );
  # Purpose    : Removes spam that exceeds age as defined in t-w.conf.
  # Returns    : 0 - failure, 1 - success
  # Parameters : path - path to a maildir

results in the Spam folder of a maildir with messages older than X days removed.

get_maildir_paths
  ############################################
  # Usage      : $toaster->get_maildir_paths()
  # Purpose    : build a list of email dirs to perform actions upon
  # Returns    : an array listing every maildir on a Mail::Toaster
  # Throws     : exception on failure, or 0 if fatal=>0

This sub creates a list of all the domains on a Mail::Toaster, and then creates a list of every email box (maildir) on every domain, thus generating a list of every mailbox on the system.

maildir_learn_spam
  ############################################
  # Usage      : $toaster->maildir_learn_spam( 
  #                  path => '/home/domains/example.com/user',
  #              );
  # Purpose    : find spam messages newer than the last spam learning run
  # Returns    : 0 - failure, 1 - success
  # Results    : matching spam messages are appended to a tmpfile to be
  #              fed to sa-learn via the caller.
  # Parameters : path - path to a maildir
  # Throws     : no exceptions
  # See Also   : learn_mailboxes
  # Comments   : this is for a single mailbox
maildir_clean_trash
  ############################################
  # Usage      : $toaster->maildir_clean_trash( 
  #                 path => '/home/domains/example.com/user',
  #              );
  # Purpose    : expire old messages in Trash folders
  # Returns    : 0 - failure, 1 - success
  # Results    : a Trash folder with messages older than X days pruned
  # Parameters : path - path to a maildir
  # Throws     : no exceptions

Comments: Removes messages in .Trash folders that exceed the number of days defined in toaster-watcher.conf.

maidir_clean_sent
  ############################################
  # Usage      : $toaster->maidir_clean_sent(
  #                 path => '/home/domains/example.com/user',
  #              );
  # Purpose    : expire old messages in Sent folders
  # Returns    : 0 - failure, 1 - success
  # Results    : messages over X days in Sent folders are deleted
  # Parameters : path - path to a maildir
  # Throws     : no exceptions
maildir_clean_new
  ############ maildir_clean_new #############
  # Usage      : $toaster->maildir_clean_new(
  #                 path => '/home/domains/example.com/user',
  #              );
  # Purpose    : expire unread messages older than X days
  # Returns    : 0 - failure, 1 - success
  # Parameters : path - path to a maildir
  # Throws     : no exceptions

  This should be set to a large value, such as 180 or 365. Odds are, if a user hasn't read their messages in that amount of time, they never will so we should clean them out.
maildir_clean_ham
  ############################################
  # Usage      : $toaster->maildir_clean_ham(
  #                 path => '/home/domains/example.com/user',
  #              );
  # Purpose    : prune read email messages
  # Returns    : 0 - failure, 1 - success
  # Results    : an INBOX minus read messages older than X days
  # Parameters : path - path to a maildir
  # Throws     : no exceptions
maildir_learn_ham
  ############################################
  # Usage      : $toaster->maildir_learn_ham(
  #                 path => '/home/domains/example.com/user',
  #              );
  # Purpose    : find ham messages newer than the last learning run
  # Returns    : 0 - failure, 1 - success
  # Results    : matching ham messages are appended to a tmpfile to be
  #              fed to sa-learn via the caller.
  # Parameters : path - path to a maildir
  # Throws     : no exceptions
  # See Also   : learn_mailboxes
  # Comments   : this is for a single mailbox
service_dir_create

Create the supervised services directory (if it doesn't exist).

        $toaster->service_dir_create();

Also sets the permissions to 775.

service_dir_test

Makes sure the service directory is set up properly

        $toaster->service_dir_test();

Also sets the permissions to 775.

service_symlinks

Sets up the supervised mail services for Mail::Toaster

    $toaster->service_symlinks();

This populates the supervised service directory (default: /var/service) with symlinks to the supervise control directories (typically /var/qmail/supervise/). Creates and sets permissions on the following directories and files:

    /var/service/pop3
    /var/service/smtp
    /var/service/send
    /var/service/submit
supervise_dirs_create

Creates the qmail supervise directories.

        $toaster->supervise_dirs_create(debug=>$debug);

The default directories created are:

  $supervise/smtp
  $supervise/submit
  $supervise/send
  $supervise/pop3

unless otherwise specified in $conf

supervised_dir_test

Checks a supervised directory to see if it is set up properly for supervise to start it. It performs a bunch of tests including:

 • directory exists
 • dir/run file exists and is executable
 • dir/down file is not present
 • dir/log exists
 • dir/log/run exists and is executable
 • dir/log/down does not exist

 arguments required:
    prot - a protocol to check (smtp, pop3, send, submit)

 arguments optional:
    debug 
supervise_restart

Restarts a supervised process.

test_processes

Tests to see if all the processes on your Mail::Toaster that should be running in fact are.

 usage:
    $toaster->test_processes();

 arguments optional:
    debug

SEE ALSO ^

The following man (perldoc) pages:

  Mail::Toaster 
  Mail::Toaster::Conf
  toaster.conf 
  toaster-watcher.conf

  http://www.mail-toaster.org/

DIAGNOSTICS ^

Since the functions in the module are primarily called by toaster-watcher.pl, they are designed to do their work with a minimum amount of feedback, complaining only when a problem is encountered. Whether or not they produce status messages and verbose errors is governed by the "debug" argument which is passed to each sub/function.

Status messages and verbose logging is enabled by default. toaster-watcher.pl and most of the automated tests (see t/toaster-watcher.t and t/Toaster.t) explicitely turns this off by setting debug=>0.

CONFIGURATION AND ENVIRONMENT ^

The primary means of configuration for Mail::Toaster is via toaster-watcher.conf. It is typically installed in /usr/local/etc, but may also be found in /opt/local/etc, or simply /etc. Documentation for the man settings in toaster-watcher.conf can be found in the man page (perldoc toaster-watcher.conf).

DEPENDENCIES ^

    Params::Validate - must be installed seperately
    POSIX (floor only - included with Perl)
    Mail::Toaster::Perl
    Mail::Toaster::Utility

BUGS AND LIMITATIONS ^

There are no known bugs in this module. Please report problems to author Patches are welcome.

TODO ^

  Add support for Darwin (MacOS X) - done
  Add support for Linux - done
  Update openssl & courier ssl .cnf files  - done
  Install an optional stub DNS resolver (dnscache)

AUTHOR ^

Matt Simerson (matt@tnpi.net)

LICENCE AND COPYRIGHT ^

Copyright (c) 2004-2008, The Network People, Inc. <matt@tnpi.net>. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the The Network People, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax highlighting: