e-monsite/mailcow-php-client

dev-main 2022-05-31 16:27 UTC

This package is auto-updated.

Last update: 2024-08-30 01:38:21 UTC


README

mailcow 是一款完整的电子邮件解决方案,具有高级反垃圾邮件、防病毒、友好的界面和 API。为了使用此 API,您需要创建一个 API 密钥并将您的 IP 地址添加到允许的 IP 列表的白名单中。这可以通过使用管理员账户登录到 Mailcow UI 来完成,然后转到配置 > 访问 > 编辑管理员详细信息 > API。在那里您将找到一个折叠的 API 菜单。有两种类型的 API 密钥 - 只读密钥只能用于所有 GET 端点 - 读写密钥可用于所有端点。

此 PHP 包由 Swagger Codegen 项目自动生成

  • API 版本:1.0.0
  • 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen

需求

PHP 5.5 及更高版本

安装 & 使用

Composer

要使用 Composer 安装绑定,请将以下内容添加到 composer.json

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com//e-monsite/mailcow-php-client.git"
    }
  ],
  "require": {
    "e-monsite/mailcow-php-client": "*@dev"
  }
}

然后运行 composer install

手动安装

下载文件并包含 autoload.php

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请按照 安装过程 进行操作,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: ApiKeyAuth
$config = MailCow\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailCow\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');

$apiInstance = new MailCow\Api\AddressRewritingApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \MailCow\Models\AddBccBody(); // \MailCow\Models\AddBccBody | 

try {
    $result = $apiInstance->createBCCMap($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AddressRewritingApi->createBCCMap: ', $e->getMessage(), PHP_EOL;
}

// Configure API key authorization: ApiKeyAuth
$config = MailCow\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailCow\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');

$apiInstance = new MailCow\Api\AddressRewritingApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \MailCow\Models\AddRecipientMapBody(); // \MailCow\Models\AddRecipientMapBody | 

try {
    $result = $apiInstance->createRecipientMap($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AddressRewritingApi->createRecipientMap: ', $e->getMessage(), PHP_EOL;
}

// Configure API key authorization: ApiKeyAuth
$config = MailCow\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailCow\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');

$apiInstance = new MailCow\Api\AddressRewritingApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \MailCow\Models\DeleteBccBody(); // \MailCow\Models\DeleteBccBody | 

try {
    $result = $apiInstance->deleteBCCMap($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AddressRewritingApi->deleteBCCMap: ', $e->getMessage(), PHP_EOL;
}

// Configure API key authorization: ApiKeyAuth
$config = MailCow\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailCow\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');

$apiInstance = new MailCow\Api\AddressRewritingApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \MailCow\Models\DeleteRecipientMapBody(); // \MailCow\Models\DeleteRecipientMapBody | 

try {
    $result = $apiInstance->deleteRecipientMap($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AddressRewritingApi->deleteRecipientMap: ', $e->getMessage(), PHP_EOL;
}

// Configure API key authorization: ApiKeyAuth
$config = MailCow\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailCow\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');

$apiInstance = new MailCow\Api\AddressRewritingApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$id = "id_example"; // string | id of entry you want to get
$x_api_key = "x_api_key_example"; // string | e.g. api-key-string

try {
    $apiInstance->getBCCMap($id, $x_api_key);
} catch (Exception $e) {
    echo 'Exception when calling AddressRewritingApi->getBCCMap: ', $e->getMessage(), PHP_EOL;
}

// Configure API key authorization: ApiKeyAuth
$config = MailCow\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailCow\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-Key', 'Bearer');

$apiInstance = new MailCow\Api\AddressRewritingApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$id = "id_example"; // string | id of entry you want to get
$x_api_key = "x_api_key_example"; // string | e.g. api-key-string

try {
    $apiInstance->getRecipientMap($id, $x_api_key);
} catch (Exception $e) {
    echo 'Exception when calling AddressRewritingApi->getRecipientMap: ', $e->getMessage(), PHP_EOL;
}
?>

API 端点文档

所有 URI 都是相对于 https://raw.githubusercontent.com/

模型文档

授权文档

ApiKeyAuth

  • 类型:API 密钥
  • API 密钥参数名:X-API-Key
  • 位置:HTTP 头部

作者