Skip to content

Commit 90f5b75

Browse files
author
Yansell Rivas Diaz
committed
fix(bundle) fix service class Mailer
* added changed of latest tags version
1 parent e76175f commit 90f5b75

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Service/Mailer.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public function __construct(ContainerInterface $container, Environment $templati
5555
* @param array $attachments
5656
* @return bool
5757
*/
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) {
5959
$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);
6161
}
6262

6363
/**
@@ -72,8 +72,8 @@ public function sendFromTemplate($from, $to, $cc, $bcc, $subject, $template, $pa
7272
* @param array $attachments
7373
* @return bool
7474
*/
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);
7777
}
7878

7979
/**
@@ -367,6 +367,7 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec
367367
$uniqueId = (is_array($from) && count($from) > 0) ? key($from) : $from;
368368
if(!$smtp) {
369369
$smtp = $em->getRepository(Smtp::class)->findOneBy(array("uniqueId" => strtolower($uniqueId)));
370+
}
370371

371372
if (!$smtp) {
372373
$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
419420

420421
$from = (is_array($message->getFrom())) ? join(', ', array_keys($message->getFrom())) : $message->getFrom();
421422
$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+
422426
$email->setFilename($filename);
423427
$email->setPath($smtp->getSpoolDir()."/");
424428
$email->setMessageFrom($from);
425-
$email->setMessageCc($cc);
426-
$email->setMessageBcc($bcc);
429+
$email->setMessageCc($ccRecipients);
430+
$email->setMessageBcc($bccRecipients);
427431
$email->setMessageTo($recipients);
428432
$email->setMessageSubject($message->getSubject());
429433
$email->setMessageBody($message->getBody());

0 commit comments

Comments
 (0)