emailit/emailit-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

emailit/emailit-sdk

最新稳定版本:v1.0.1

Composer 安装命令:

composer require emailit/emailit-sdk

包简介

EmailIt SDK for PHP

README 文档

README

A PHP SDK for interacting with the EmailIt API, allowing you to send emails, manage audiences, credentials, sending domains, and events.

Table of Contents

  1. Requirements
  2. Installation
  3. Basic Usage
  4. Features
  5. Examples
  6. Error Handling

Requirements

  • PHP 7.3 or higher
  • cURL extension enabled

Installation

You have two options for installing the EmailIt SDK:

Option 1: Using Composer (Recommended)

composer require emailit/emailit-sdk

Then in your PHP script:

require 'vendor/autoload.php';

use EmailIt\EmailItClient;

$client = new EmailItClient('your_api_key');

Option 2: Manual Installation

  1. Download the latest release from GitHub
  2. Include the autoloader in your PHP script:
require_once 'path/to/emailit-sdk/autoload.php';

use EmailIt\EmailItClient;

$client = new EmailItClient('your_api_key');

Basic Usage

Initialize the Client

use EmailIt\EmailItClient;

$client = new EmailItClient('your_api_key');

Send an Email

$email = $client->email();
$email->from('sender@example.com')
      ->to('recipient@example.com')
      ->replyTo('reply@example.com')
      ->subject('Test Email')
      ->html('<h1>Hello, World!</h1>')
      ->text('This is a test email.')
      ->send();

Features

Email Management

The EmailBuilder class provides a fluent interface for creating and sending emails:

$email = $client->email();
$email->from('sender@example.com')
      ->to('recipient@example.com')
      ->replyTo('reply@example.com')
      ->subject('Test Email')
      ->html('<h1>Hello, World!</h1>')
      ->text('This is a test email.')
      ->addAttachment('file.pdf', $fileContent, 'application/pdf')
      ->addHeader('X-Custom-Header', 'Value')
      ->send();

Audience Management

Manage your email audiences:

$audiences = $client->audiences();

// List audiences
$list = $audiences->list(25, 1, 'Newsletter');

// Create audience
$newAudience = $audiences->create('New Newsletter');

// Subscribe a user
$audiences->subscribe(
    'audience_token',
    'user@example.com',
    'John',
    'Doe',
    ['interests' => 'technology']
);

Credential Management

Handle SMTP and API credentials:

$credentials = $client->credentials();

// List credentials
$list = $credentials->list(25, 1, null, 'smtp');

// Create credential
$newCredential = $credentials->create('Main SMTP', 'smtp');

Sending Domain Management

Manage your sending domains:

$domains = $client->sendingDomains();

// List domains
$list = $domains->list(25, 1, 'example.com');

// Create domain
$newDomain = $domains->create('emails.example.com');

// Check DNS records
$dnsStatus = $domains->checkDns('domain_id');

Event Management

Track email-related events:

$events = $client->events();

// List events
$list = $events->list(25, 1, 'email.delivery.sent');

// Get specific event
$event = $events->get('event_id');

Error Handling

The SDK uses the EmailItException class for error handling:

use EmailIt\EmailItException;

try {
    $result = $client->email()
        ->from('sender@example.com')
        ->to('recipient@example.com')
        ->subject('Test')
        ->html('<p>Content</p>')
        ->send();
} catch (EmailItException $e) {
    echo 'Error: ' . $e->getMessage();
    echo 'Code: ' . $e->getCode();
}

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-06