Created
April 2, 2014 18:13
Flushing the email memory spool in a symfony command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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