Implement IMAP email-to-ticket gateway

This commit is contained in:
macktic committed 2026-10-10 16:22:56 +01:00
1 parent b7e5884457
commit 6f25869345
33 files changed
+5619 -5

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Box\Mod\Mailgateway;
use Pimple\Container;
class TemplateInstaller
{
public function __construct(private Container $di) {}
public function install(): void
{
$code = 'mailgateway_sender_mismatch';
$email = $this->di['mod_service']('email');
// Preserve existing custom content and enabled/disabled preference.
if ($email->getTemplateRepository()->findOneByActionCode($code) !== null) {
return;
}
$source = file_get_contents(__DIR__ . '/templates/email/' . $code . '.html.twig');
if (!is_string($source)
|| !preg_match('/{%\s*block subject\s*%}(.*?){%\s*endblock\s*%}/s', $source, $subject)
|| !preg_match('/{%\s*block content\s*%}(.*?){%\s*endblock\s*%}/s', $source, $content)) {
throw new \RuntimeException('Mail Gateway sender-mismatch template is missing or invalid');
}
// This existing custom action code does not use the mod_* discovery convention.
$email->templateCreate($code, trim($subject[1]), trim($content[1]), 1, 'mailgateway');
}
}