Improve sending of mailings.

This commit is contained in:
Martin Kamerbeek 2010-05-20 11:59:07 +02:00
parent e7dd066630
commit b7b1811387
3 changed files with 60 additions and 16 deletions

View file

@ -47,7 +47,7 @@ sub execute {
my $maxTime = time + $self->getTTL;
# For now only process test mails.
# First send all queued test emails.
my $it = WebGUI::Mailing::Email->getQueuedTestEmails( $session );
while ( my $email = $it->() ) {
return $self->WAITING(1) if time >= $maxTime;
@ -55,14 +55,13 @@ sub execute {
$email->send;
}
my $it = WebGUI::Mailing::Email->getSendableEmails( $session );
while ( my $email = $it->() ) {
$session->log->warn( "processing" . $email->getId );
# Fetch mailings that are scheduled to be sent one by one, and send them.
while ( my $mailing = WebGUI::Mailing->getNextInSendQueue( $session ) ) {
return $self->WAITING(1) if time >= $maxTime;
$email->send;
$mailing->sendQueuedEmails( $maxTime ) || return $self->WAITING(1);
}
return $self->COMPLETE;
}