@@ -55,9 +55,9 @@ public function __construct(ContainerInterface $container, EngineInterface $temp
55
55
* @param array $attachments
56
56
* @return bool
57
57
*/
58
- public function sendFromTemplate ($ from , $ to , $ cc , $ bcc , $ subject , $ template , $ parameters = array (), $ attachments = array ()) {
58
+ public function sendFromTemplate ($ from , $ to , $ cc , $ bcc , $ subject , $ template , $ parameters = array (), $ attachments = array (), $ smtp = null ) {
59
59
$ html = $ this ->templating ->render ($ template , $ parameters );
60
- return $ this ->sendEmail ($ from , $ to , $ cc , $ bcc , $ subject , $ html , $ attachments );
60
+ return $ this ->sendEmail ($ from , $ to , $ cc , $ bcc , $ subject , $ html , $ attachments, $ smtp );
61
61
}
62
62
63
63
/**
@@ -72,8 +72,8 @@ public function sendFromTemplate($from, $to, $cc, $bcc, $subject, $template, $pa
72
72
* @param array $attachments
73
73
* @return bool
74
74
*/
75
- public function sendEmail ($ from , $ to , $ cc , $ bcc , $ subject , $ html , $ attachments = array ()) {
76
- return $ this ->processEmail ($ from , $ to , $ cc , $ bcc , $ subject , $ html , $ attachments );
75
+ public function sendEmail ($ from , $ to , $ cc , $ bcc , $ subject , $ html , $ attachments = array (), $ smtp = null ) {
76
+ return $ this ->processEmail ($ from , $ to , $ cc , $ bcc , $ subject , $ html , $ attachments, $ smtp );
77
77
}
78
78
79
79
/**
@@ -295,7 +295,7 @@ private function embedBase64Images(\Swift_Message $message, $body)
295
295
* @param array $attachments
296
296
* @return bool
297
297
*/
298
- private function processEmail ($ from , $ to , $ cc = array (), $ bcc = array (), $ subject , $ html = "" , $ attachments = array ()) {
298
+ private function processEmail ($ from , $ to , $ cc = array (), $ bcc = array (), $ subject , $ html = "" , $ attachments = array (), $ smtp = null ) {
299
299
300
300
if ($ this ->devMode ) {
301
301
$ to = $ this ->devTo ;
@@ -364,8 +364,10 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec
364
364
$ em = $ this ->container ->get ('doctrine ' )->getManager ();
365
365
366
366
/** @var Smtp $smtp */
367
- $ uniqueId = (is_array ($ from ) && count ($ from ) > 0 ) ? $ from [0 ] : $ from ;
368
- $ smtp = $ em ->getRepository (Smtp::class)->findOneBy (array ("uniqueId " => strtolower ($ uniqueId )));
367
+ $ uniqueId = (is_array ($ from ) && count ($ from ) > 0 ) ? key ($ from ) : $ from ;
368
+ if (!$ smtp ) {
369
+ $ smtp = $ em ->getRepository (Smtp::class)->findOneBy (array ("uniqueId " => strtolower ($ uniqueId )));
370
+ }
369
371
370
372
if (!$ smtp ) {
371
373
$ this ->container ->get ('logger ' )->log (\Monolog \Logger::WARNING , "Unable to find an SMTP configuration with the UniqueID of {$ from }" );
0 commit comments