Skip to content

Commit

Permalink
Merge pull request #9 from whernandez/master
Browse files Browse the repository at this point in the history
Fix Mailer service calling namespace Smtp::class
  • Loading branch information
angelbencosme authored Jun 28, 2022
2 parents 8887d2e + d34f843 commit c53f695
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Service/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Mailer {

/** @var Environment $templating */
private $templating;

/** @var bool $devMode */
private $devMode = false;

Expand Down Expand Up @@ -132,8 +132,8 @@ public function check(OutputInterface $output = null) {

$em = $this->container->get('doctrine')->getManager();

$configurations = $em->getRepository('NTIEmailBundle:Smtp')->findAll();
$configurations = $em->getRepository(Smtp::class)->findAll();

/** @var Smtp $smtp */
foreach ($configurations as $smtp){
$this->handleSmtpSpool($smtp, $output);
Expand Down Expand Up @@ -195,7 +195,7 @@ public function handleSmtpSpool(Smtp $smtp, OutputInterface $output = null){
$filename = null;
$tempSpoolPath = $email->getPath().$email->getHash()."/";
// Read the temporary spool path
$files = scandir($tempSpoolPath, SORT_ASC);
$files = scandir($tempSpoolPath, SORT_ASC);
foreach($files as $file) {
if ($file == "." || $file == "..") continue;
$filename = $file;
Expand Down Expand Up @@ -230,7 +230,7 @@ public function handleSmtpSpool(Smtp $smtp, OutputInterface $output = null){
}
}
try {
$em->flush();
$em->flush();
} catch (\Exception $ex) {
$this->container->get('logger')->log(\Monolog\Logger::CRITICAL, StringUtilities::BeautifyException($ex));
}
Expand Down Expand Up @@ -308,7 +308,7 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec
$this->container->get('logger')->log(\Monolog\Logger::CRITICAL, "At least one email is required");
return false;
}

/** @var Swift_Message $message */
$message = new \Swift_Message($subject);
$message->setFrom($from);
Expand All @@ -331,7 +331,7 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec

if(is_array($bcc)) {
foreach($bcc as $recipient) {
if($recipient != "" && filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
if($recipient != "" && filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
$message->addBcc($recipient);
}
}
Expand Down Expand Up @@ -413,9 +413,9 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec
} catch (\Exception $ex) {
$this->container->get('logger')->log(\Monolog\Logger::CRITICAL, StringUtilities::BeautifyException($ex));
}

}

// Save the email and delete the hash directory
$em = $this->container->get('doctrine')->getManager();
$email = new Email();
Expand All @@ -424,7 +424,7 @@ private function processEmail($from, $to, $cc = array(), $bcc = array(), $subjec
$recipients = (is_array($message->getTo())) ? join(', ', array_keys($message->getTo())) : $message->getTo();
$ccRecipients = (is_array($message->getCc())) ? join(', ', array_keys($message->getCc())) : $message->getCc();
$bccRecipients = (is_array($message->getBcc())) ? join(', ', array_keys($message->getBcc())) : $message->getBcc();

$email->setFilename($filename);
$email->setPath($smtp->getSpoolDir()."/");
$email->setMessageFrom($from);
Expand Down

0 comments on commit c53f695

Please sign in to comment.