<?php
declare(strict_types=1);
namespace Nextag\Mail\Helper;
use Symfony\Component\Mime\Email;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
use Twig\Extra\CssInliner\CssInlinerExtension;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Adapter\Translation\Translator;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Content\Mail\Service\AbstractMailSender;
use League\Flysystem\FilesystemInterface;
use Mpdf\Mpdf;
use Mpdf\Config\ConfigVariables;
use Mpdf\Config\FontVariables;
/**
* Class MailGenerator
* @package Nextag\Flow\Helper
*/
class MailGenerator
{
protected $configService;
protected $log;
private $twig;
private $translator;
private $mailSender;
protected FilesystemInterface $filesystem;
protected $nextagCheckoutRepository;
protected $customerGroupRepository;
protected $customerRepository;
protected $baseUrl;
public function __construct(
\Shopware\Core\System\SystemConfig\SystemConfigService $configService,
Translator $translator,
\Twig\Environment $twig,
AbstractMailSender $mailSender,
FilesystemInterface $filesystem,
\Nextag\Mail\Helper\Log $log,
EntityRepositoryInterface $customerGroupRepository,
EntityRepositoryInterface $customerRepository
) {
$this->configService = $configService;
$this->twig = $twig;
try {
$this->twig->getExtension("Twig\Extra\CssInliner\CssInlinerExtension");
} catch (\Exception $e) {
$this->twig->addExtension(new CssInlinerExtension());
}
$this->mailSender = $mailSender;
$this->filesystem = $filesystem;
$this->translator = $translator;
$this->log = $log;
$this->customerGroupRepository = $customerGroupRepository;
$this->customerRepository = $customerRepository;
$this->baseUrl = $this->configService->get("NextagConnector.config.shopwareBaseUrl");
}
/**
* @param mixed $identifier
* @param mixed $subject
* @param array $parameters
* @return Email
* @throws LoaderError
* @throws RuntimeError
* @throws SyntaxError
*/
public function getMessage($identifier, $from, $sendTo, $bcc, $subject, $data = [], $attachments = null, $binAttachments = null)
{
try {
$templateName = 'storefront/mail/' . $identifier . '.html.twig';
$template = $this->twig->loadTemplate($this->twig->getTemplateClass($templateName), $templateName);
$bodyHtml = $template->renderBlock('body_html', $data);
$email = (new Email())->subject($subject);
$email->html($bodyHtml);
if ($attachments !== null) {
foreach ($attachments as $url) {
$email->embed($this->filesystem->read($url) ?: '', basename($url), $this->filesystem->getMimetype($url) ?: null);
}
}
if (isset($binAttachments)) {
foreach ($binAttachments as $binAttachment) {
$email->embed(
$binAttachment['content'],
$binAttachment['fileName'],
$binAttachment['mimeType']
);
}
}
$email->from($from);
$email->addTo(...$sendTo);
if ($bcc && is_array($bcc) && !empty($bcc)) {
foreach ($bcc as $k => $v) {
if (trim($bcc[$k]) == "") {
unset($bcc[$k]);
}
}
}
if ($bcc && !empty($bcc)) {
$email->addBcc(...$bcc);
}
return $email;
} catch (\Exception $exception) {
$this->log->error($exception);
}
}
public function sendEmail($order, $config, $orderExtension = null)
{
try {
$this->log->info("sendEmail start");
$type = null;
$to = null;
$bcc = null;
if (isset($config['mailType'])) {
$type = $config['mailType'];
} else {
$this->log->error(new \Exception('No mail type defined for order ' . $order->getOrderNumber()));
return false;
}
if (isset($config['email'])) {
$to = $config['email'];
} else {
$this->log->error(new \Exception('No send to defined for mail: ' . $type . ' for order ' . $order->getOrderNumber()));
return false;
}
if (isset($config['bccEmail'])) {
$bcc = $config['bccEmail'];
}
setlocale(LC_ALL, "de_CH.UTF-8");
$subject = '';
switch ($type) {
case 'orderConfirmation':
$subject = 'Danke für Ihre Bestellung (' . $order->getOrderNumber() . ')';
break;
case 'orderConfirmationInternal':
$subject = 'Neue Online-Bestellung Nr. ' . $order->getOrderNumber();
break;
}
$requestScheme = "https";
if (isset($_SERVER["REQUEST_SCHEME"])) {
$requestScheme = $_SERVER["REQUEST_SCHEME"];
}
$data = array(
'baseUrl' => $requestScheme . "://" . $_SERVER["SERVER_NAME"],
'order' => $order,
'orderUrl' => $requestScheme . "://" . $_SERVER["SERVER_NAME"] . "/account/order",
'checkoutExtension' => $orderExtension
);
if (isset($config["exportorder"]) && isset($config["exportorder"]["result"])) {
if ($config["exportorder"]["result"] === false) {
$data["exportResult"] = "2";
$subject .= " - Import fehlgeschlagen!";
} else {
$data["exportResult"] = "1";
}
}
$from = $this->configService->get("core.basicInformation.email");
if ($this->configService->get("core.basicInformation.shopName")) {
$from = "Weinhandlung Martel" . ' <' . $from . '>'; // $this->configService->get("core.basicInformation.shopName")
}
$context = \Shopware\Core\Framework\Context::createDefaultContext();
$groupId = $order->getOrderCustomer()->getCustomer()->getGroupId();
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter(
'id',
$groupId
));
$customerGroup = $this->customerGroupRepository->search($criteria, $context)->first();
$data['customerGroup'] = $customerGroup;
$data['orderDateTime'] = date('d.m.Y / H:i:s', $order->getOrderDateTime()->getTimestamp());
// generate pdf
$attachments = [];
$context = \Shopware\Core\Framework\Context::createDefaultContext();
$pdf = $this->createOrderPdf($order, $data);
if ($pdf) {
$attachment = [
'content' => file_get_contents($pdf),
'fileName' => pathinfo($pdf, PATHINFO_BASENAME),
'mimeType' => mime_content_type($pdf)
];
$attachments[] = $attachment;
}
// $events = $this->createEventPdfs($order,$data);
// if (!empty($events)) {
// foreach($events as $event) {
// $attachment = [
// 'content' => file_get_contents($event),
// 'fileName' => pathinfo($event, PATHINFO_BASENAME),
// 'mimeType' => mime_content_type($event)
// ];
// $attachments[] = $attachment;
// }
// }
$email = $this->getMessage(
strtolower($type . "_withpdf"),
$from,
$this->getEmailAddresses($to, $order),
$this->getEmailAddresses($bcc, $order),
$subject,
$data,
null,
$attachments
);
/* if ($requestScheme . "://" . $_SERVER["SERVER_NAME"] == "https://martel.dev5") {
// generate pdf
$attachments = [];
$orderNumber = $order->getOrdernumber();
$context = \Shopware\Core\Framework\Context::createDefaultContext();
$pdf = $this->createOrderPdf($order, $data);
if ($pdf) {
$attachment = [
'content' => file_get_contents($pdf),
'fileName' => pathinfo($pdf, PATHINFO_BASENAME),
'mimeType' => mime_content_type($pdf)
];
$attachments[] = $attachment;
}
$email = $this->getMessage(
strtolower($type."_withpdf"),
$from,
$this->getEmailAddresses($to, $order),
$this->getEmailAddresses($bcc, $order),
$subject,
$data,
null,
$attachments
);
} else {
$email = $this->getMessage(
strtolower($type),
$from,
$this->getEmailAddresses($to, $order),
$this->getEmailAddresses($bcc, $order),
$subject,
$data
);
} */
$this->mailSender->send($email);
if (is_array($to)) {
$logTo = implode(",", $to);
} else {
$logTo = [$to];
}
foreach ($logTo as $k => $v) {
if ($v == "[KUNDE]") {
$logTo[$k] = $order->getOrderCustomer()->getEmail();
}
}
$this->log->info('Mail (' . $type . ') wurde gesendet an: ' . implode(",", $logTo) . ' (Bestellnummer: ' . $order->getOrderNumber() . ')');
$this->log->info("sendEmail END");
} catch (\Exception $e) {
$this->log->error($e);
}
}
public function createOrderPdf($order, $data)
{
try {
if ($order) {
$showDetails = true;
$language = "de";
$context = \Shopware\Core\Framework\Context::createDefaultContext();
$orderCustomer = $order->getOrderCustomer();
if ($orderCustomer->getCustomer()) {
$customer = $orderCustomer->getCustomer();
} else {
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter("email", $orderCustomer->getEmail()));
$criteria->addFilter(new EqualsFilter("guest", false));
$customer = $this->customerRepository->search($criteria, $context)->first();
if (!$customer) {
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter("email", $orderCustomer->getEmail()));
$criteria->addFilter(new EqualsFilter("guest", true));
}
}
$items = json_decode(json_encode($order->getLineItems()), true);
$templateName = 'storefront/pdf/order.html.twig';
$template = $this->twig->loadTemplate($this->twig->getTemplateClass($templateName), $templateName);
$data["customer"] = $customer;
$data["imageBasePath"] = $this->baseUrl . '/images';
$data["context"] = $context;
if ($showDetails == "true") {
$data["showDetails"] = true;
$data["maxpage"] = ceil(sizeof($items) / 4);
} else {
$data["showDetails"] = false;
$data["maxpage"] = ceil(sizeof($items) / 20);
}
$html = $template->renderBlock('body_html', $data);
$defaultConfig = (new ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
if ($showDetails == "true") {
$mpdf = new Mpdf([
'mode' => 'utf-8',
'format' => 'A4',
'margin_left' => 10,
'margin_right' => 10,
'margin_top' => 15,
'margin_bottom' => 25,
'orientation' => 'P',
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/fonts',
]),
'fontdata' => $fontData + [
'thesans' => [
'R' => 'TheSans_B2_500_.ttf',
'B' => 'TheSans_B2_700_.ttf'
],
'slimbach' => [
'R' => 'SlimbachEF-Book.ttf'
],
],
'default_font' => 'thesans',
'default_font_size' => 11
]);
} else {
$mpdf = new Mpdf([
'mode' => 'utf-8',
'format' => 'A4-L',
'margin_left' => 10,
'margin_right' => 10,
'margin_top' => 15,
'margin_bottom' => 25,
'orientation' => 'P',
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/fonts',
]),
'fontdata' => $fontData + [
'thesans' => [
'R' => 'TheSans_B2_500_.ttf',
'B' => 'TheSans_B2_700_.ttf'
],
'slimbach' => [
'R' => 'SlimbachEF-Book.ttf'
],
],
'default_font' => 'thesans',
'default_font_size' => 11
]);
}
$mpdf->showImageErrors = true;
$mpdf->defaultheaderline = 0;
$mpdf->defaultfooterline = 0;
$mpdf->defaultfooterfontstyle = 'R';
if ($language == "en") {
$title = "Martel_Order_" . trim(str_replace("`", "", str_replace("'", "", $order->getOrderNumber())));
} elseif ($language == "fr") {
$title = "Martel_Commande_" . trim(str_replace("`", "", str_replace("'", "", $order->getOrderNumber())));
} else {
$title = "Martel_Bestellung_" . trim(str_replace("`", "", str_replace("'", "", $order->getOrderNumber())));
}
$filename = $title . ".pdf";
$mpdf->setTitle($title);
if ($showDetails == "false") {
// $mpdf->SetHTMLFooter('
// <table width="100%">
// <tr>
// <td width="33%" align="right" style="padding-right: 30px;">Seite {PAGENO} von {nbpg}</td>
// </tr>
// </table>');
}
$mpdf->writeHTML($html);
$basePath = $this->configService->get("NextagMail.config.pdfFilepath");
$filepath = $basePath . "/" . $title . ".pdf";
$mpdf->Output($filepath, 'F');
return $filepath;
}
} catch (\Exception $e) {
$this->log->error($e, false);
return $e->getmessage();
}
}
public function createEventPdfs($order, $data)
{
try {
$files = [];
if ($order) {
$context = \Shopware\Core\Framework\Context::createDefaultContext();
$orderCustomer = $order->getOrderCustomer();
if ($orderCustomer->getCustomer()) {
$customer = $orderCustomer->getCustomer();
} else {
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter("email", $orderCustomer->getEmail()));
$criteria->addFilter(new EqualsFilter("guest", false));
$customer = $this->customerRepository->search($criteria, $context)->first();
if (!$customer) {
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter("email", $orderCustomer->getEmail()));
$criteria->addFilter(new EqualsFilter("guest", true));
}
}
$fileCounter = 1;
foreach ($order->getLineItems() as $lineItem) {
$payload = $lineItem->getPayload();
if ($payload && isset($payload["customData"]) && !is_array($payload["customData"])) {
if (isset($payload["isEvent"]) && $payload["isEvent"] == true) {
$language = "de";
//$templateName = 'storefront/pdf/event.html.twig';
//$template = $this->twig->loadTemplate($this->twig->getTemplateClass($templateName), $templateName);
$data["customer"] = $customer;
$data["order"] = $order;
$data["lineItem"] = $lineItem;
$data["payload"] = $payload;
$data["imageBasePath"] = $this->baseUrl . '/images';
$data["context"] = $context;
//$html = $template->renderBlock('body_html', $data);
$html = '<img src="https://www.martel.ch/images/event/martel-event-pdf-bg-05.png" style="width: 100%">';
if (!empty($payload["eventTitle"]) || !empty($payload["eventName"])) {
$eventText = !empty($payload["eventTitle"]) ? $payload["eventTitle"] : $payload["eventName"];
$html .= '<div style="position:absolute; top: 425px; left: 70px; width: 600px; height: 70px; font-family: slimbach; font-size: 38px;">' . $eventText . '</div>';
}
if($payload["eventDate"] && $payload["eventTime"] && $payload["eventLocation"]) {
$html .= '<div style="position:absolute; top: 503px; left: 70px; width: 350px; height: 120px;">';
if($payload["eventDateTextReplace"]) {
$html .= $payload["eventDateTextReplace"] . '<br>';
} else {
$html .= $payload["eventDate"] . '<br>';
}
$html .= $payload["eventTime"] . '<br>' . $payload["eventLocation"];
if($payload["eventWineConsultationBookingOptionsChoice"]) {
$html .= '<br>Degustationsberatung: ' . $payload["eventWineConsultationBookingOptionsChoice"];
}
$html .= '</div>';
}
if($payload["recipients"]) {
$html .= '<div style="position:absolute; top: 503px; left: 430px; width: 330px; height: 170px;">';
foreach ($payload["recipients"] as $user) {
$html .= $user["firstname"] . ' ' . $user["lastname"] . '<br>';
}
$html .= '</div>';
}
$html .= '<div style="font-size: 11px; position:absolute; top: 635px; left: 70px; width: 200px; height: 20px;">Ausstelldatum: ' . date("d.m.y") . '</div>';
$defaultConfig = (new ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$mpdf = new Mpdf([
'mode' => 'utf-8',
'format' => 'A4',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'orientation' => 'P',
'fontDir' => array_merge($fontDirs, [
__DIR__ . '/fonts',
]),
'fontdata' => $fontData + [
'thesans' => [
'R' => 'TheSans_B2_500_.ttf',
'B' => 'TheSans_B2_700_.ttf'
],
'slimbach' => [
'R' => 'SlimbachEF-Book.ttf'
],
],
'default_font' => 'thesans',
'default_font_size' => 11
]);
$mpdf->showImageErrors = true;
$mpdf->defaultheaderline = 0;
$mpdf->defaultfooterline = 0;
$mpdf->defaultfooterfontstyle = 'R';
if ($language == "en") {
$title = "Martel_Event-Ticket_" . trim(str_replace("`", "", str_replace("'", "", $order->getOrderNumber() . "_" . $fileCounter)));
} elseif ($language == "fr") {
$title = "Martel_Event-Ticket_" . trim(str_replace("`", "", str_replace("'", "", $order->getOrderNumber() . "_" . $fileCounter)));
} else {
$title = "Martel_Event-Ticket_" . trim(str_replace("`", "", str_replace("'", "", $order->getOrderNumber() . "_" . $fileCounter)));
}
$filename = $title . ".pdf";
$mpdf->setTitle($title);
if (isset($showDetails) && $showDetails == "false") {
// $mpdf->SetHTMLFooter('
// <table width="100%">
// <tr>
// <td width="33%" align="right" style="padding-right: 30px;">Seite {PAGENO} von {nbpg}</td>
// </tr>
// </table>');
}
$mpdf->writeHTML($html);
$basePath = $this->configService->get("NextagMail.config.pdfFilepath");
$filepath = $basePath . "/" . $title . ".pdf";
$mpdf->Output($filepath, 'F');
$files[] = $filepath;
}
}
$fileCounter++;
}
}
return $files;
} catch (\Exception $e) {
$this->log->error($e, false);
return $e->getmessage();
}
}
public function processOrderEmails($order, $config, $orderExtension = null)
{
try {
if ($config["orderconfirmation"]["status"]) {
$config["mailType"] = "orderConfirmation";
$config['email'] = $config["orderconfirmation"]["email"];
$config['bccEmail'] = $config["orderconfirmation"]["bccEmail"];
$this->sendEmail($order, $config, $orderExtension);
}
if ($config["orderconfirmationinternal"]["status"]) {
$config["mailType"] = "orderConfirmationInternal";
$config['email'] = $config["orderconfirmationinternal"]["email"];
$config['bccEmail'] = $config["orderconfirmationinternal"]["bccEmail"];
$this->sendEmail($order, $config, $orderExtension);
}
} catch (\Exception $e) {
$this->log->error($e);
}
}
private function getEmailAddresses($emails, $order)
{
$emailArr = [];
$emailsSplit = explode(',', $emails);
foreach ($emailsSplit as $mail) {
$mailStr = trim($mail);
if ($mailStr === '[KUNDE]') {
$emailArr[] = trim($order->getOrderCustomer()->getFirstname() . " " . $order->getOrderCustomer()->getLastname()) . ' <' . $order->getOrderCustomer()->getEmail() . '>';
} else {
$emailArr[] = $mailStr;
}
}
return $emailArr;
}
public function sendAccountDeleteRequest($customer, $data)
{
try {
setlocale(LC_ALL, "de_CH.UTF-8");
$subject = "Martel Online-Shop: Anfrage zum Löschen eines Kundenkontos";
$type = "accountdeleterequest";
$from = $this->configService->get("core.basicInformation.email");
if ($this->configService->get("core.basicInformation.shopName")) {
$from = $this->configService->get("core.basicInformation.shopName") . ' <' . $from . '>';
} else {
$from = "Martel Online Shop" . ' <' . $from . '>';
}
$mimeType = "application/json";
$sendTo = [$this->configService->get("core.basicInformation.email")];
if ($sendTo) {
$email = $this->getMessage(
$type,
$from,
$sendTo,
['technik@nextag.ch'],
$subject,
$data,
[],
[]
);
}
$this->mailSender->send($email);
} catch (\Exception $e) {
$this->log->error($e);
}
}
public function sendExportOrderError($filepath)
{
try {
setlocale(LC_ALL, "de_CH.UTF-8");
$subject = "Fehler in Martel Online-Shop: Bestellung konnte nicht nach Abacus übertragen werden";
$type = "exportordererror";
$data = [];
$from = $this->configService->get("core.basicInformation.email");
if ($this->configService->get("core.basicInformation.shopName")) {
$from = $this->configService->get("core.basicInformation.shopName") . ' <' . $from . '>';
} else {
$from = "Martel Online Shop" . ' <' . $from . '>';
}
$mimeType = "application/json";
$filename = explode("/", $filepath);
$attachment = [
'content' => file_get_contents($filepath),
'fileName' => $filename[sizeof($filename) - 1],
'mimeType' => $mimeType
];
$attachments[] = $attachment;
$sendTo = explode(",", $this->configService->get("NextagStoremanager.config.exportSendTo"));
if ($sendTo) {
$email = $this->getMessage(
$type,
$from,
$sendTo,
['technik@nextag.ch'],
$subject,
$data,
[],
$attachments
);
}
$this->mailSender->send($email);
} catch (\Exception $e) {
$this->log->error($e);
}
}
public function sendExportOrderMissingError($errors, $type)
{
try {
setlocale(LC_ALL, "de_CH.UTF-8");
$subject = "Fehler in Martel Online-Shop: Bestellung konnte nicht nach " . $type . " übertragen werden";
$type = "exportordermissingerror";
$data["errors"] = implode("<br>", $errors);
$from = $this->configService->get("core.basicInformation.email");
if ($this->configService->get("core.basicInformation.shopName")) {
$from = $this->configService->get("core.basicInformation.shopName") . ' <' . $from . '>';
} else {
$from = "Martel Online Shop" . ' <' . $from . '>';
}
$sendTo = explode(",", $this->configService->get("NextagStoremanager.config.errorSendTo"));
if ($sendTo) {
$email = $this->getMessage(
$type,
$from,
$sendTo,
[],
$subject,
$data,
[],
[]
);
}
$this->mailSender->send($email);
} catch (\Exception $e) {
$this->log->error($e);
}
}
public function sendAddressChange($oldAddress, $newAddressJsonArray, $filepath)
{
try {
setlocale(LC_ALL, "de_CH.UTF-8");
$this->log->info("sendAddressChange start");
$subject = "Adressänderung in Martel Online-Shop";
$type = "addresschange";
$data = [
"oldAddress" => $oldAddress,
"newAddress" => $newAddressJsonArray
];
$from = $this->configService->get("core.basicInformation.email");
if ($this->configService->get("core.basicInformation.shopName")) {
$from = $this->configService->get("core.basicInformation.shopName") . ' <' . $from . '>';
} else {
$from = "Marrtel Online Shop" . ' <' . $from . '>';
}
$mimeType = "application/json";
$this->log->info("filepath" . $filepath);
$filename = explode("/", $filepath);
$this->log->info("before attachment");
$attachment = [
'content' => file_get_contents($filepath),
'fileName' => $filename[sizeof($filename) - 1],
'mimeType' => $mimeType
];
$attachments[] = $attachment;
$sendTo = explode(",", $this->configService->get("NextagStoremanager.config.exportSendToAddressChange"));
$this->log->info("before send");
if ($sendTo) {
$email = $this->getMessage(
$type,
$from,
$sendTo,
['technik@nextag.ch'],
$subject,
$data,
null,
$attachments
);
}
$this->mailSender->send($email);
$this->log->info("sendAddressChange end");
} catch (\Exception $e) {
$this->log->error($e);
}
}
public function sendErrorMail($errormessage)
{
try {
setlocale(LC_ALL, "de_CH.UTF-8");
$subject = "Martel Online-Shop Fehlermeldung: " . $errormessage;
$type = "error";
$data = [
"message" => $errormessage
];
$from = $this->configService->get("core.basicInformation.email");
if ($this->configService->get("core.basicInformation.shopName")) {
$from = $this->configService->get("core.basicInformation.shopName") . ' <' . $from . '>';
} else {
$from = "Martel Online Shop" . ' <' . $from . '>';
}
$attachments = [];
$sendTo = explode(",", $this->configService->get("NextagStoremanager.config.errorSendTo"));
$email = $this->getMessage(
$type,
$from,
$sendTo,
null,
$subject,
$data,
null,
$attachments
);
$this->mailSender->send($email);
} catch (\Exception $e) {
$this->log->error($e);
}
}
public function sendImportErrorLog($filepath)
{
try {
setlocale(LC_ALL, "de_CH.UTF-8");
$subject = "Martel Online-Shop: fehlende Preise";
$type = "importproductlog";
$data = [];
$from = $this->configService->get("core.basicInformation.email");
if ($this->configService->get("core.basicInformation.shopName")) {
$from = $this->configService->get("core.basicInformation.shopName") . ' <' . $from . '>';
} else {
$from = "Martel Online Shop" . ' <' . $from . '>';
}
$mimeType = "application/json";
$filename = explode("/", $filepath);
$attachment = [
'content' => file_get_contents($filepath),
'fileName' => $filename[sizeof($filename) - 1],
'mimeType' => $mimeType
];
$attachments[] = $attachment;
$sendTo = explode(",", $this->configService->get("NextagStoremanager.config.exportSendTo"));
$email = $this->getMessage(
$type,
$from,
$sendTo,
['technik@nextag.ch'],
$subject,
$data,
null,
$attachments
);
$this->mailSender->send($email);
} catch (\Exception $e) {
$this->log->error($e);
}
}
}