Skip to content

Instantly share code, notes, and snippets.

@peterjmit
Created April 2, 2014 18:13
Show Gist options
  • Save peterjmit/9939846 to your computer and use it in GitHub Desktop.
Save peterjmit/9939846 to your computer and use it in GitHub Desktop.
Flushing the email memory spool in a symfony command
<?php
$mailer = $this->getContainer()->get('mailer');
$message = new \Swift_Message();
$message->setBody('');
$message->setSubject('');
$message->setTo('');
$message->setFrom('');
$mailer->send($message);
$spool = $mailer->getTransport()->getSpool();
// flush the spool if we are in developer mode
if ($spool instanceof \Swift_MemorySpool) {
$transport = $this->getContainer()->get('swiftmailer.transport.real');
$spool->flushQueue($transport);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment