NAME

DADA::Mail::MailOut - Helps Monitor a Mass Mailout


VERSION

Refer to the version of Dada Mail that this module comes in.


SYNOPSIS

    # A few subroutines, exported by default: 
    
    my @mailouts  = DADA::Mail::MailOut::current_mailouts($list);  
 
    my $exists    = DADA::Mail::MailOut::mailout_exists($list, $id, $type); 
    
 
 
     
    # Create a new DADA::Mail::MailOut object: 
    my $mailout = DADA::Mail::MailOut->new(-List => $list); 
    
    # Make a new Mailout: 
    $mailout->create(
                    -fields   => {%fields},
                    -list_type => 'list',
                    -mh_obj    => $mh_obj,  
               ); 
    
    # how's that mailout doin'?
    my $status = $mailout->status; 
    
    # do I need to reload the mailout? 
    my $yes_restart = $mailout->should_be_restarted; 
    
    # if so, let's do that: 
    if($yes_restart){ 
        $mailout->reload();  
    }


DESCRIPTION

This module does a few things, all of which happen to deal with setting up a mass mailing and then monitoring its status.

Mass Mailings do take a while and the CGI environment that Dada Mail is run in, isn't the best thing to be in during a long-running process, like mail sending to a few thousand of your closest friends.

Because of that, this module attempts to keep close track of how the mailing is doing and give an option to reload a mailing at the time it stopped. Mailings usually stop because the mailing process itself can be killed by the server itself.

The create() method does most of the magic in getting a mailing setup. When called correctly, it will make a temporary directory (usually in $TMP that holds within it the following files:


SUBROUTINES/METHODS

new

Takes one argument - the list shortname, ala:

    my $mailout = DADA::Mail::MailOut->new({-List => 'listshortname'});

All there is to it.

Note! that a MailOut object is pretty useless, until you call the, create() method.

create

Used to setup, or, ``create'' a mailout. Makes all the temporary files and directories need. Needs a few things passed - do pay attention, since what it needs is slightly odd:

 $mailout->create(
                    -fields   => {%fields},
                    -list_type => 'list',
                    -mh_obj    => $mh_obj,  
               );

You'll most likely never call create() yourself, but that's the jist of it.

associate

 $mailout->associate($id, $type);

associate associates an already existing mailing with the object you have on hand - similar to create, but doesn't create anything - it just allows you to work with something you already have.

It takes two arguments - both of which are required. Not passing them will cause your program to croak.

Returns 1 on success.

batch_lock

    $mailout->batch_lock;

Locks a mailout. The presence of a lock prohibits a different process from reloading a mailout that looks as if it is stopped.

You shouldn't really ever remove a batch lock (although I know this is tempting), as doing so won't explicitly make a mailing restart right away - there are a few things that come in play when it is decided a mailout should be restarted.

The batch lock itself is just a plain text file. Its contents are the unix time of when the batch was locked.

Returns, 1 on success.

unlock_batch_lock

    $mailout->unlock_batch_lock;

unlinks (removes) a batch lock. Will return 1 on success and 0 upon failure.

There's a few reasons why this may fail:

is_batch_locked

    $mailout->is_batch_locked

Looks and see if the batch lock is present. Returns 1 if it is, 0 if it isn't. This method does not see if the batch is stale.

create_directory

mailout_directory_name

create_subscriber_list

create_total_sending_out_num

create_counter

create_first_accessed_file

create_last_accessed_file

create_batch_lock

countsubscriber

create_raw_message

_integrity_check

status

Although you may never call create, calling status may be much more commonplace.

 my $status = $mailout->status;

or even:

foreach(keys %{$mailout->status}){ print $_; # or... something... }

status returns a hashref of various information about your mailout. Best not to call this too many times at once, as it does query all those temporary files we've created. I'll go over what you're most likely going to use:

should_be_restarted

process_has_stalled

process_stalled_after

mail_fields_from_raw_message

_poll

reload

counter_at

message_for_mail_send

clean_up

current_mailouts

mailout_exists

_list_name_check

_list_exists


DIAGNOSTICS


BUGS AND LIMITATIONS

Please report problems to the author of this module


AUTHOR

Justin Simoni

See: http://mojo.skazat.com/contact


LICENCE AND COPYRIGHT

Copyright (c) 2006 - 2007 Justin Simoni All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.