mimepost/mimepost-php

v1.0 2021-01-16 12:47 UTC

This package is auto-updated.

Last update: 2024-09-18 17:42:52 UTC


README

MimePost API 用于发送电子邮件。您可以在 https://mimepost.com 上了解更多关于 MimePost 的信息。要获取 X-Auth-Token 的值,您需要首先在 MimePost 上注册

Latest Version Known Vulnerabilities codecov.io Code Coverage Total Downloads HitCount MIT licensed

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

  • API 版本:0.1.0
  • 构建包:io.swagger.codegen.languages.PhpClientCodegen

需求

PHP 5.5 及以上版本

安装 & 使用

Composer

要通过 Composer 安装绑定,请运行以下命令

composer require mimepost/mimepost-php

然后运行 composer install

包含 autoload.php

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

入门指南

请遵循 安装过程,然后运行以下命令

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

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

$apiInstance = new MimePost\Client\Php\EmailsApi(
    // 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 \MimePost\Client\Model\Email(); // \Swagger\Client\Model\Email | Single Email object
$body->setSubject('This is a subject');
$body->setFromEmail('from@example.com');
$body->setTo(array( array('email' => 'receiver@example.com') )); 
$body->setHtml('<p>This is a test email send using MimePost PHP SDK</p>');

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

测试

运行单元测试

./vendor/bin/phpunit

提示:对于测试,您可以使用 api 密钥 special-key 来测试授权过滤器。

API 端点文档

所有 URI 都是相对于 https://api.mimepost.com/v1/

模型文档

授权文档

api_key

  • 类型:API密钥
  • API密钥参数名称:X-Auth-Token
  • 位置:HTTP头

作者

support@mimepost.com