定制 flysend/flysend-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

flysend/flysend-php

最新稳定版本:v1.0.0

Composer 安装命令:

composer require flysend/flysend-php

包简介

FlySend PHP SDK for sending emails via the FlySend API.

README 文档

README

The official PHP SDK for FlySend — send transactional emails through the FlySend API.

Works with any PHP project. No framework dependencies.

Requirements

  • PHP 8.2+
  • cURL extension

Installation

composer require flysend/flysend-php

Quick Start

use FlySend\FlySend;

$flysend = new FlySend('your-api-key');

$response = $flysend->emails->send([
    'from' => 'hello@example.com',
    'to' => 'user@example.com',
    'subject' => 'Welcome!',
    'html' => '<p>Hello world!</p>',
]);

echo $response['data']['id']; // email ID

Configuration

$flysend = new FlySend(
    apiKey: 'your-api-key',
    baseUrl: 'https://api.flysend.co', // optional, for self-hosted instances
    timeout: 30,                        // optional, default 30s
);

Send Email

$response = $flysend->emails->send([
    'from'    => 'Company <hello@example.com>',
    'to'      => 'user@example.com',
    'subject' => 'Welcome!',
    'html'    => '<p>Hello!</p>',
    'text'    => 'Hello!',                              // optional
    'cc'      => 'cc@example.com',                      // optional
    'bcc'     => 'bcc@example.com',                     // optional
    'reply_to' => 'support@example.com',                // optional
    'tags'    => [                                      // optional
        ['name' => 'campaign', 'value' => 'welcome'],
    ],
    'attachments' => [                                  // optional
        [
            'filename'  => 'invoice.pdf',
            'content'   => base64_encode($pdfContent),
            'mime_type' => 'application/pdf',
        ],
    ],
]);

echo $response['data']['id']; // email ID

Batch Send

Send up to 100 emails in a single request:

$response = $flysend->emails->batch([
    [
        'from'    => 'hello@example.com',
        'to'      => 'user1@example.com',
        'subject' => 'Hello User 1',
        'html'    => '<p>Hi!</p>',
    ],
    [
        'from'    => 'hello@example.com',
        'to'      => 'user2@example.com',
        'subject' => 'Hello User 2',
        'html'    => '<p>Hi!</p>',
    ],
]);

echo $response['queued_count']; // number of emails queued
echo $response['error_count'];  // number of failures

Error Handling

use FlySend\Exceptions\FlySendException;
use FlySend\Exceptions\QuotaExceededException;
use FlySend\Exceptions\ValidationException;

try {
    $flysend->emails->send([...]);
} catch (QuotaExceededException $e) {
    echo 'Quota exceeded. Remaining: ' . $e->quota['remaining'];
    echo 'Resets at: ' . $e->quota['resets_at'];
} catch (ValidationException $e) {
    echo 'Validation errors: ';
    print_r($e->errors); // ['field' => ['error message', ...]]
} catch (FlySendException $e) {
    echo 'API error: ' . $e->getMessage();
    echo 'Status code: ' . $e->getStatusCode();
}

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固