mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-10-28 05:05:41 +00:00
31 lines
1.0 KiB
PHP
31 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Mailcow\Identity\Legacy;
|
|
|
|
use Mailcow\MailboxGroup\Legacy\LegacyMailbox;
|
|
|
|
/**
|
|
* Bridge to the procedural mailbox code for the IdP sync: creating mailboxes, applying templates.
|
|
*/
|
|
class LegacyAccounts extends LegacyMailbox
|
|
{
|
|
/**
|
|
* Creates a mailbox of the IdP from a template, like the IdP login does.
|
|
*
|
|
* @return ?string null on success, else the message key of the legacy error
|
|
*/
|
|
public function createMailbox(string $email, string $name, string $authsource, string $template): ?string
|
|
{
|
|
return $this->asSystem(fn(): mixed => $this->callCreate($email, $name, $authsource, $template));
|
|
}
|
|
|
|
protected function callCreate(string $email, string $name, string $authsource, string $template): mixed
|
|
{
|
|
[$local, $domain] = explode('@', $email, 2);
|
|
return mailbox('add', 'mailbox_from_template', ['domain' => $domain, 'local_part' => $local, 'name' => $name,
|
|
'authsource' => $authsource, 'template' => $template]);
|
|
}
|
|
}
|