BatchSend echo message after 20 messages sent

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
User avatar
batfastad
Forum Contributor
Posts: 433
Joined: Tue Mar 30, 2004 4:24 am
Location: London, UK

BatchSend echo message after 20 messages sent

Post by batfastad »

Hi everyone
I have a very quick question relating to the batchsend() method

My script performs several steps before calling swift and starting the send, I've got my own error checking routine to make sure that all goes ok.

Is it possible to show a message after Swift has successfully sent 20 or so messages?
Just to let the user know the potentially lengthy process of sending has started.
Then the user will know that everything's ok with the start of the script, and that sending is underway

Thanks, B
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: BatchSend echo message after 20 messages sent

Post by Chris Corbyn »

Write a SendListener plugin:

Code: Select all

class Every20Plugin implements Swift_Events_SendListener {
  private $_sendCount = 0;
  public function sendPerformed(Swift_Events_SendEvent $evt) {
    $this->_sendCount++;
    if (($this->_sendCount % 20) == 0) {
      printf("%s Messages sent\n", $this->_sendCount);
    }
  }
}
 
$swift->attachPlugin(new Every20Plugin(), 'SomeKey');
Post Reply