public static function createMailManager(ContainerInterface $container): MailManager
    {
        $manager = new MailManager($container->get('config'), $container->get(TransportFactory::class));
        $manager->setContainer($container);

        if ($container->has(ViewFactoryContract::class)) {
            $manager->setViewFactory($container->get(ViewFactoryContract::class));
        }

        if ($container->has(EventManagerContract::class)) {
            $manager->setEventManager($container->get(EventManagerContract::class));
        }

        return $manager;
    }