@@ -137,6 +137,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
137
137
)
138
138
);
139
139
}
140
+
141
+ // FIXME: Workaround, waiting for https://github.com/symfony/SwiftmailerBundle/pull/64
142
+ // to be merged
143
+ $ this ->flushMailQueue ();
140
144
}
141
145
142
146
/**
@@ -208,4 +212,35 @@ private function decodeConfiguration($data)
208
212
209
213
throw new \InvalidArgumentException ($ error );
210
214
}
215
+
216
+ /**
217
+ * @see Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onKernelTerminate
218
+ * and https://github.com/symfony/SwiftmailerBundle/pull/64
219
+ */
220
+ public function flushMailQueue ()
221
+ {
222
+ if (!$ this ->getContainer ()->has ('mailer ' )) {
223
+ return ;
224
+ }
225
+
226
+ $ mailers = array_keys ($ this ->getContainer ()->getParameter ('swiftmailer.mailers ' ));
227
+ foreach ($ mailers as $ name ) {
228
+ if ($ this ->getContainer () instanceof IntrospectableContainerInterface ?
229
+ $ this ->getContainer ()->initialized (sprintf ('swiftmailer.mailer.%s ' , $ name )) : true ) {
230
+ if ($ this ->getContainer ()->getParameter (sprintf ('swiftmailer.mailer.%s.spool.enabled ' , $ name ))) {
231
+ $ mailer = $ this ->getContainer ()->get (sprintf ('swiftmailer.mailer.%s ' , $ name ));
232
+ $ transport = $ mailer ->getTransport ();
233
+ if ($ transport instanceof \Swift_Transport_SpoolTransport) {
234
+ $ spool = $ transport ->getSpool ();
235
+ if ($ spool instanceof \Swift_MemorySpool) {
236
+ $ spool ->flushQueue (
237
+ $ this ->getContainer ()->get (sprintf ('swiftmailer.mailer.%s.transport.real ' , $ name ))
238
+ );
239
+ }
240
+ }
241
+ }
242
+ }
243
+ }
244
+
245
+ }
211
246
}
0 commit comments