Mail-Toaster

 view release on metacpan or  search on metacpan

lib/Mail/Toaster/Qmail.pm  view on Meta::CPAN

package Mail::Toaster::Qmail;
use strict;
use warnings;

our $VERSION = '5.53';

use Carp;
use English qw( -no_match_vars );
use File::Copy;
use File::Path;
use Params::Validate qw( :all );
use POSIX;
use Sys::Hostname;

use lib 'lib';
use parent 'Mail::Toaster::Base';

sub build_pop3_run {
    my $self = shift;
    my %p = validate( @_, { $self->get_std_opts } );

    $self->get_supervise_dir or return;

    my @lines = $self->toaster->supervised_do_not_edit_notice(1);

    if ( $self->conf->{pop3_hostname} eq 'qmail' ) {
        push @lines, $self->supervised_hostname_qmail( 'pop3' );
    };

#qmail-popup mail.cadillac.net /usr/local/vpopmail/bin/vchkpw qmail-pop3d Maildir 2>&1
    my $exec = $self->toaster->supervised_tcpserver( 'pop3' ) or return;
    my $chkpass = $self->_set_checkpasswd_bin( prot => 'pop3' ) or return;

    $exec .= "\\\n\tqmail-popup ";
    $exec .= $self->toaster->supervised_hostname( "pop3" );
    $exec .= "$chkpass qmail-pop3d Maildir ";
    $exec .= $self->toaster->supervised_log_method( "pop3" );

    push @lines, $exec;

    my $file = '/tmp/toaster-watcher-pop3-runfile';
    $self->util->file_write( $file, lines => \@lines ) or return;
    $self->install_supervise_run( tmpfile => $file, prot => 'pop3' ) or return;
    return 1;
}

sub build_send_run {
    my $self = shift;
    my %p = validate( @_, { $self->get_std_opts } );
    my %args = $self->get_std_args( %p );

    $self->audit( "generating send/run..." );

    $self->get_supervise_dir or return;

    my $mailbox  = $self->conf->{send_mailbox_string} || './Maildir/';
    my $send_log = $self->conf->{send_log_method}     || 'syslog';

    my @lines = $self->toaster->supervised_do_not_edit_notice;

    if ( $send_log eq 'syslog' ) {
        push @lines, "# use splogger to qmail-send logs to syslog\n
# make changes in /usr/local/etc/toaster-watcher.conf
exec qmail-start $mailbox splogger qmail\n";
    }
    else {
        push @lines, "# sends logs to multilog as directed in log/run
# make changes in /usr/local/etc/toaster-watcher.conf
exec qmail-start $mailbox 2>&1\n";
    }

    my $file = "/tmp/toaster-watcher-send-runfile";
    $self->util->file_write( $file, lines => \@lines, fatal => 0) or return;
    $self->install_supervise_run( tmpfile => $file, prot => 'send'  ) or return;
    return 1;
}

sub build_smtp_run {
    my $self = shift;
    my %p = validate( @_, { $self->get_std_opts } );
    my %args = $self->toaster->get_std_args( %p );

    $self->audit( "generating supervise/smtp/run...");

    $self->_test_smtpd_config_values() or return;

    my $mem;

    my @smtp_run_cmd = $self->toaster->supervised_do_not_edit_notice(1);
    push @smtp_run_cmd, $self->smtp_set_qmailqueue();
    push @smtp_run_cmd, $self->smtp_get_simenv();

    $self->get_control_dir or return; # verify control directory exists
    $self->get_supervise_dir or return;



( run in 0.849 second using v1.01-cache-2.11-cpan-364913b4093 )