NAME

Mail::Toaster:::Qmail - Common Qmail functions

SYNOPSIS

Mail::Toaster::Qmail is frequently used functions I've written for perl use with Qmail.

DESCRIPTION

This module has all sorts of goodies, the most useful of which are the Build????Run modules which build your qmail control files for you.

GetListOfRWLs

use Mail::Toaster::Qmail
my $list = GetListOfRWLs($conf, $debug);

Here we collect a list of the RWLs from the configuration file that get's passed to us. We return an arrayref with a list of the enabled ones.

TestEachRBL

use Mail::Toaster::Qmail
my $list = TestEachRBL($arrayref, $debug);

We get a list of RBL's in an arrayref and we run some tests on them to determine if they are working correctly. We return a list of the correctly functioning RBLs.

GetListOfRBLs

use Mail::Toaster::Qmail
my $list = GetListOfRBLs($arrayref, $debug);

We get passwd a configuration file (toaster-watcher.conf) and from it we extract all the RBL's the user has selected and return them as an array ref.

BuildSendRun

use Mail::Toaster::Qmail;
if ( BuildSendRun($conf, $file, $debug) ) { print "success"};

BuildSendRun generates a supervise run file for qmail-send. $file is the location of the file it's going to generate. $conf is a list of configuration variables pulled from a config file (see ParseConfigfile). I typically use it like this:

my $file = "/tmp/toaster-watcher-send-runfile";
if ( BuildSendRun($conf, $file ) )
{
	InstallQmailServiceRun($file, "$supervise/send/run");
};

If it succeeds in building the file, it will install it. You can optionally restart qmail after installing a new run file.

BuildPOP3Run

use Mail::Toaster::Qmail;
if ( BuildPOP3Run($conf, $file, $debug) ) { print "success"};

Generate a supervise run file for qmail-pop3d. $file is the location of the file it's going to generate. $conf is a list of configuration variables pulled from a config file (see ParseConfigfile). I typically use it like this:

my $file = "/tmp/toaster-watcher-pop3-runfile";
if ( BuildPOP3Run($conf, $file ) )
{
	InstallQmailServiceRun($file, "$supervise/pop3/run");
};

If it succeeds in building the file, it will install it. You can optionally restart the service after installing a new run file.

TestSmtpdConfigValues

SetServiceDir

This is necessary because things such as service directories are now in /var by default but older versions of my toaster installed them in /. This will detect and adjust for that.

BuildSmtpRun

use Mail::Toaster::Qmail;
if ( BuildSmtpRun($conf, $file, $debug) ) { print "success"};

Generate a supervise run file for qmail-smtpd. $file is the location of the file it's going to generate. $conf is a list of configuration variables pulled from a config file (see ParseConfigfile). I typically use it like this:

my $file = "/tmp/toaster-watcher-smtpd-runfile";
if ( BuildSmtpRun($conf, $file ) )
{
	InstallQmailServiceRun($file, "$supervise/smtp/run");
};

If it succeeds in building the file, it will install it. You can optionally restart the service after installing a new run file.

BuildSubmitRun

use Mail::Toaster::Qmail;
if ( BuildSubmitRun($conf, $file, $debug) ) { print "success"};

Generate a supervise run file for qmail-smtpd running on submit. $file is the location of the file it's going to generate. $conf is a list of configuration variables pulled from a config file (see ParseConfigfile). I typically use it like this:

my $file = "/tmp/toaster-watcher-smtpd-runfile";
if ( BuildSubmitRun($conf, $file ) )
{
	InstallQmailServiceRun($file, "$supervise/submit/run");
};

If it succeeds in building the file, it will install it. You can optionally restart the service after installing a new run file.

InstallQmailServiceRun

use Mail::Toaster::Qmail;

my $file = "/tmp/toaster-watcher-smtpd-runfile";
if ( BuildSmtpRun($conf, $file ) )
{
	InstallQmailServiceRun($file, "$supervise/smtp/run");
};

The code says it as well as I can.

RestartQmailSmtpd

RestartQmailSmtpd($dir, $debug)

Use RestartQmailSmtpd to restart the qmail-smtpd process. It will send qmail-smtpd the TERM signal causing it to exit. It will restart immediately (supervise).

StopQmailSend

StopQmailSend

Use StopQmailSend to quit the qmail-send process. It will send qmail-send the TERM signal and then wait until it's shut down before returning. If qmail-send fails to shut down within 100 seconds, then we force kill it, causing it to abort any outbound SMTP sessions that are active. This is safe, as qmail will attempt to deliver them again, and again until it succeeds.

StartQmailSend

StartQmailSend - Start up the qmail-send process.

After starting up qmail-send, we verify that it's running before returning.

ProcessQmailQueue

ProcessQmailQueue - Tell qmail to process the queue immediately

CheckRcpthosts

use Mail::Toaster::Qmail;
CheckRcpthosts($qmaildir);

Checks the rcpthosts file and compare it to users/assign. Any zones that are in users/assign but not in control/rcpthosts or control/morercpthosts will be presented as a list and you'll be expected to add them to morercpthosts.

ConfigQmail

use Mail::Toaster::Qmail;
ConfigQmail($qmaildir, $host, $postmaster, $conf);

Qmail is fantastic because it's so easy to configure. Just edit files and put the right values in them. However, many find that a problem because it's not so easy to always know the sytax for what goes in every file, and exactly where that file might be. This sub takes your values from toaster-watcher.conf and puts them where they need to be. It modifies the following files:

/var/qmail/control/concurrencyremote
/var/qmail/control/me
/var/qmail/control/tarpitcount
/var/qmail/control/tarpitdelay
/var/qmail/control/sql
/var/qmail/alias/.qmail-postmaster
/var/qmail/alias/.qmail-root
/var/qmail/alias/.qmail-mailer-daemon

ConfigureQmailControl

use Mail::Toaster::Qmail;
ConfigureQmailControl($conf);

Installs the qmail control script as well as the startup (services.sh) script.

InstallQmailSuperviseRunFiles

use Mail::Toaster::Qmail;
InstallQmailSuperviseRunFiles($conf, $supervise);

$conf is a hashref of values pulled from toaster-watcher.conf. $supervise is your qmail supervise directory.

Generates the qmail/supervise/*/run files based on your settings.

InstallQmailSuperviseLogRunFiles

use Mail::Toaster::Qmail;
InstallQmailSuperviseLogRunFiles($conf);

$conf is a hash of values. See ParseConfigFile or toaster-watcher.conf for config values.

Installs the files the control your supervised processes logging. Typically this consists of qmail-smtpd, qmail-send, and qmail-pop3d. The generated files are:

$supervise/pop3/log/run
$supervise/smtp/log/run
$supervise/send/log/run

GetDomainsFromAssign

Fetch a list of domains from the qmaildir/users/assign file.

	use Mail::Toaster::Qmail;
	GetDomainsFromAssign($assign, $debug, $match, $value);

 $assign is the path to the assign file.
 $debug is optional
 $match is an optional field to match (dom, uid, dir)
 $value is the pattern to  match

AUTHOR

Matt Simerson <matt@cadillac.net>

BUGS

None known. Report any to author.

TODO

SEE ALSO

http://www.tnpi.biz/computing/ http://www.tnpi.biz/internet/mail/toaster/

Mail::Toaster::CGI, Mail::Toaster::DNS, Mail::Toaster::Logs, Mail::Toaster::Qmail, Mail::Toaster::Setup

COPYRIGHT

Copyright 2003, The Network People, Inc. All Rights Reserved.