@@ -55,9 +55,9 @@ public function __construct(ContainerInterface $container, Environment $templati
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
/**
@@ -367,6 +367,7 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec
367
367
$ uniqueId = (is_array ($ from ) && count ($ from ) > 0 ) ? key ($ from ) : $ from ;
368
368
if (!$ smtp ) {
369
369
$ smtp = $ em ->getRepository (Smtp::class)->findOneBy (array ("uniqueId " => strtolower ($ uniqueId )));
370
+ }
370
371
371
372
if (!$ smtp ) {
372
373
$ this ->container ->get ('logger ' )->log (\Monolog \Logger::WARNING , "Unable to find an SMTP configuration with the UniqueID of {$ from }" );
@@ -419,11 +420,14 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec
419
420
420
421
$ from = (is_array ($ message ->getFrom ())) ? join (', ' , array_keys ($ message ->getFrom ())) : $ message ->getFrom ();
421
422
$ recipients = (is_array ($ message ->getTo ())) ? join (', ' , array_keys ($ message ->getTo ())) : $ message ->getTo ();
423
+ $ ccRecipients = (is_array ($ message ->getCc ())) ? join (', ' , array_keys ($ message ->getCc ())) : $ message ->getCc ();
424
+ $ bccRecipients = (is_array ($ message ->getBcc ())) ? join (', ' , array_keys ($ message ->getBcc ())) : $ message ->getBcc ();
425
+
422
426
$ email ->setFilename ($ filename );
423
427
$ email ->setPath ($ smtp ->getSpoolDir ()."/ " );
424
428
$ email ->setMessageFrom ($ from );
425
- $ email ->setMessageCc ($ cc );
426
- $ email ->setMessageBcc ($ bcc );
429
+ $ email ->setMessageCc ($ ccRecipients );
430
+ $ email ->setMessageBcc ($ bccRecipients );
427
431
$ email ->setMessageTo ($ recipients );
428
432
$ email ->setMessageSubject ($ message ->getSubject ());
429
433
$ email ->setMessageBody ($ message ->getBody ());
0 commit comments