Page 1 of 1

BatchSend echo message after 20 messages sent

Posted: Fri May 23, 2008 9:17 am
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

Re: BatchSend echo message after 20 messages sent

Posted: Fri May 23, 2008 5:39 pm
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');