diff --git a/gestion/lib/Controller/InvoiceController.php b/gestion/lib/Controller/InvoiceController.php index e43efdd..6c22a80 100644 --- a/gestion/lib/Controller/InvoiceController.php +++ b/gestion/lib/Controller/InvoiceController.php @@ -1,6 +1,7 @@ mailer = $mailer; $this->gestionRepository = $bdd; $this->mailerService = $mailerService; + $this->config = $config; try{ $this->storage = $rootFolder->getUserFolder($this->currentUserIdNextcloud); @@ -93,6 +98,12 @@ class InvoiceController extends Controller $factureContent = $factureGeneratedResponse["content"]; $factureDate = DateHelpers::convertInvoiceDateToMonthAndYearOnly($facture['date_paiement']); try { + $senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null; + $senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null; + $senderEmail = null; + if($senderEmailAddress && $senderEmailDomain){ + $senderEmail = $senderEmailAddress.'@'.$senderEmailDomain; + } $message = $this->mailer->createMessage(); $message->setTo(recipients: [$email => "Facture"]); $content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf"); @@ -106,6 +117,9 @@ class InvoiceController extends Controller "

Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .

". $signature ); + if($senderEmail != null){ + $message->setCc([$senderEmail]); + } $this->mailer->send($message); $this->gestionRepository->setFactureSentDate($factureId); } catch (Exception $e) { diff --git a/gestion/lib/Controller/PageController.php b/gestion/lib/Controller/PageController.php index 62fdd04..becb02c 100644 --- a/gestion/lib/Controller/PageController.php +++ b/gestion/lib/Controller/PageController.php @@ -1590,6 +1590,12 @@ class PageController extends Controller { $devis = $this->myDb->getDevisOfDefunt($defuntId); if($devis != null){ // try { + $senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null; + $senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null; + $senderEmail = null; + if($senderEmailAddress && $senderEmailDomain){ + $senderEmail = $senderEmailAddress.'@'.$senderEmailDomain; + } $client_email = $to; $client_nom = $devis['client_nom']; $data = $this->storage->get($ff_pdf)->getContent(); @@ -1608,6 +1614,10 @@ class PageController extends Controller { "

$body_text

". $signature ); + + if($senderEmail != null){ + $message->setCc([$senderEmail]); + } $this->mailer->send($message); return new DataResponse("", 200, ['Content-Type' => 'application/json']); // } catch (Exception $e) {