acl->checkScope(Email::ENTITY_TYPE)) { throw new Forbidden(); } $data = $request->getParsedBody(); $type = $data->type ?? null; $id = $data->id ?? null; $server = $data->server ?? null; $port = $data->port ?? null; $username = $data->username ?? null; $password = $data->password ?? null; $auth = $data->auth ?? null; $authMechanism = $data->authMechanism ?? null; $security = $data->security ?? null; $userId = $data->userId ?? null; $fromAddress = $data->fromAddress ?? null; $fromName = $data->fromName ?? null; $emailAddress = $data->emailAddress ?? null; if (!is_string($server)) { throw new BadRequest("No `server`"); } if (!is_int($port)) { throw new BadRequest("No or bad `port`."); } if (!is_string($emailAddress)) { throw new BadRequest("No `emailAddress`."); } $smtpParams = SmtpParams ::create($server, $port) ->withSecurity($security) ->withFromName($fromName) ->withFromAddress($fromAddress) ->withAuth($auth); if ($auth) { $smtpParams = $smtpParams ->withUsername($username) ->withPassword($password) ->withAuthMechanism($authMechanism); } $data = new TestSendData($emailAddress, $type, $id, $userId); $this->sendService->sendTestEmail($smtpParams, $data); return ResponseComposer::json(true); } }