{{ 'Install the required mail library before testing connections or enabling imports.'|trans }}
+ + {% else %} +{{ 'Automatic installation is unavailable on this server. Run composer install from the Mailgateway directory using SSH.'|trans }}
+ {% endif %} +{{ 'Maintenance actions preserve saved mailbox settings and existing ticket data.'|trans }}
+ {% if result.notifications is defined %} +{{ 'Ticket acknowledgement and enabled staff notification subjects are configured for email replies.'|trans }}
+ {% else %} +{{ 'Setup enables the ticket acknowledgement and adds ticket numbers to its subject and enabled staff notification subjects. Existing wording is kept.'|trans }}
+ +{{ 'Mail Gateway dependencies are installed.'|trans }}
+ {% else %} +{{ 'Mail Gateway dependencies are not installed.'|trans }}
+ {% endif %} +{{ 'Run composer install again using the module lock file, even when dependencies are already installed.'|trans }}
+ {% if result.dependencies is defined and result.dependencies.available %} + + {% else %} +{{ 'Web installation is unavailable. Run composer install from the Mailgateway directory using SSH.'|trans }}
+ {% endif %} +{{ 'Runs the same setup as php tools/setup.php. Creates missing module tables and adds the default mismatch email template if absent. Existing records and templates are kept. Composer runs separately.'|trans }}
+ +Hello,
+ ++ Thank you for contacting {{ guest.system_company.name }}. +
+ ++ Unfortunately, we couldn't add your email to the support ticket + you replied to. +
+ ++ Please reply from the email address associated + with your account. +
+ ++ For security reasons, we can only accept email replies + from an address authorised to access the support ticket. +
++ Your message has not been added to the ticket. + Please resend it using your registered email address. +
+ ++ If you no longer have access to that email address, + please log in to your account to update your details + or contact us for assistance. +
+ ++ Kind regards, +
+ +HTML
\r\n--boundary--\r\n"; +$message = \Webklex\PHPIMAP\Message::fromString($raw, $config); +$headers = \Box\Mod\Mailgateway\ImapMailbox::rawHeaders($message->getHeader()->raw); +$parsed = \Box\Mod\Mailgateway\ImapMailbox::data($message, 'support@example.com', $headers, false); +if ($parsed['sender_email'] !== 'seb@molenaar.co.uk' || $parsed['sender_name'] !== 'Seb' + || $parsed['subject'] !== 'Test é' || $parsed['content'] !== 'Plain é' || $parsed['message_id'] !== 'Hello & welcome
Second line
"; +$message = \Webklex\PHPIMAP\Message::fromString($rawHtml, $config); +$headers = \Box\Mod\Mailgateway\ImapMailbox::rawHeaders($message->getHeader()->raw); +$parsed = \Box\Mod\Mailgateway\ImapMailbox::data($message, 'support@example.com', $headers, false); +$again = \Box\Mod\Mailgateway\ImapMailbox::data($message, 'support@example.com', $headers, false); +if ($parsed['content'] !== "Hello & welcome\nSecond line" || $parsed['subject'] !== '(No subject)' || $parsed['message_id'] !== $again['message_id']) { throw new RuntimeException('HTML fallback or missing-ID fingerprint failed'); } +$headers = \Box\Mod\Mailgateway\ImapMailbox::rawHeaders("Return-Path: <>\r\nAuto-Submitted: no\r\nAuto-Submitted: auto-replied;\r\n reason=vacation\r\n"); +$policy = new \Box\Mod\Mailgateway\InboundPolicy(); +if (count($headers['auto-submitted']) !== 2 || $headers['return-path'] !== ['<>'] || $policy->ignoreReason($policy->headers(['headers' => $headers])) === null) { throw new RuntimeException('Raw automatic headers lost'); } + +$event = new \Box_Event(null, 'onBeforeAdminCronRun'); +$hookDi = new \Pimple\Container(); +$hookDi['logger'] = $pollDi['logger']; +$hookDi['mod_service'] = $hookDi->protect(fn ($module) => new class { public function poll() { throw new RuntimeException('SECRET'); } }); +$event->setDi($hookDi); +\Box\Mod\Mailgateway\Service::onBeforeAdminCronRun($event); +echo "Passed cron isolation, five-minute cadence, overlap lock, disabled mailboxes, folder routing, failure retry, move-failure deduplication, real MIME/HTML parsing, stable missing-ID tracking, raw autoresponder headers, and secret-safe logs.\n"; + +// Exercise the real transport orchestration without opening a network connection. +$imapBody = "Hello from the inbox."; +$imapHeader = "From: Seb