PHPackages                             chocoboxxf/yii2-sendcloud-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. chocoboxxf/yii2-sendcloud-sdk

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

chocoboxxf/yii2-sendcloud-sdk
=============================

SendCloud API for Yii 2.0

v0.0.1(9y ago)176MITPHPPHP &gt;=5.4.0

Since Sep 23Pushed 9y ago1 watchersCompare

[ Source](https://github.com/chocoboxxf/yii2-sendcloud-sdk)[ Packagist](https://packagist.org/packages/chocoboxxf/yii2-sendcloud-sdk)[ Docs](https://github.com/chocoboxxf/yii2-sendcloud-sdk)[ RSS](/packages/chocoboxxf-yii2-sendcloud-sdk/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

yii2-sendcloud-sdk
==================

[](#yii2-sendcloud-sdk)

基于Yii2实现的SendCloud API SDK（目前开发中）

环境条件
----

[](#环境条件)

- > = PHP 5.4
- > = Yii 2.0
- > = GuzzleHttp 6.0

安装
--

[](#安装)

添加下列代码在`composer.json`文件中并执行`composer update --no-dev`操作

```
{
    "require": {
       "chocoboxxf/yii2-sendcloud-sdk": "dev-master"
    }
}
```

设置方法
----

[](#设置方法)

```
// 全局使用
// 在config/main.php配置文件中定义component配置信息
'components' => [
  .....
  'mail' => [
    'class' => 'chocoboxxf\SendCloud\SendCloud',
    'apiUser' => 'API_USER', // API User
    'apiKey' => 'API_KEY', // API Key
    'defaultFrom' => 'default@default.com', // 缺省发件人地址
    'defaultFromName' => 'default', // 缺省发件人名称
  ]
  ....
]
// 代码中调用
$result = Yii::$app->mail->sendTemplateMail(
    'TEMPLATE_NAME',
    ['user_a@company.com', 'user_b@company.com'],
    'admin@company.com',
    'admin',
    'Welcome Letter',
    ['key1' => 'value1 for all', 'key2' => ['value2 for a', 'value2 for b']],
    ['/path/to/file1', '/path/to/file2']
);
....
```

```
// 局部调用
$mailService = Yii::createObject([
    'class' => 'chocoboxxf\SendCloud\SendCloud',
    'apiUser' => 'API_USER', // API User
    'apiKey' => 'API_KEY', // API Key
    'defaultFrom' => 'default@default.com', // 缺省发件人地址
    'defaultFromName' => 'default', // 缺省发件人名称
]);
$result = $mailService->sendTemplateMail(
    'TEMPLATE_NAME',
    ['user_a@company.com', 'user_b@company.com'],
    'admin@company.com',
    'admin',
    'Welcome Letter',
    ['key1' => 'value1 for all', 'key2' => ['value2 for a', 'value2 for b']],
    ['/path/to/file1', '/path/to/file2']
);
....
```

使用示例
----

[](#使用示例)

普通发送接口

```
$subject = '测试邮件';
$content = 'this is a test %key% html text';
$to = ['user_a@company.com', 'user_b@company.com'];
$from = 'admin@company.com';
$fromName = '管理员';
$templateData = [
    'key' => 'value',
];
$attachments = [
   '/path/to/file1',
];
$result = Yii::$app->mail->sendNormalMail($subject, $content, $to, $from, $fromName, $templateData, $attachments);
if ($result['result'] === true) {
    // 正常情况
    // 返回数据格式
    // {
    //   "statusCode": 200,
    //   "info": {
    //     "emailIdList": [
    //       "1447054895514_15555555_32350_1350.sc-10_10_126_221-inbound0$user_a@company.com",
    //       "1447054895514_15555555_32350_1350.sc-10_10_126_221-inbound1$user_b@company.com"
    //     ]
    //   },
    //   "message": "请求成功",
    //   "result": true
    // }
    ....
} else {
    // 出错情况
    // 返回数据格式
    // {
    //   "statusCode": 40863,
    //   "info": {},
    //   "message": "to中有不存在的地址列表. 参数to: user_a@company.com",
    //   "result": false
    // }
    ....
}
....
```

模板发送接口

```
$subject = '测试邮件';
$template = 'TEMPLATE_NAME';
$to = ['user_a@company.com', 'user_b@company.com'];
$from = 'admin@company.com';
$fromName = '管理员';
$templateData = [
    'key1' => 'value1 for a and b',
    'key2' => ['value2 for a', 'value2 for b']
];
$attachments = [
   '/path/to/file1',
];
$result = Yii::$app->mail->sendTemplateMail($template, $to, $from, $fromName, $subject, $templateData, $attachments);
if ($result['result'] === true) {
    // 正常情况
    // 返回数据格式
    // {
    //   "statusCode": 200,
    //   "info": {
    //     "emailIdList": [
    //       "1447054895514_15555555_32350_1350.sc-10_10_126_221-inbound0$user_a@company.com",
    //       "1447054895514_15555555_32350_1350.sc-10_10_126_221-inbound1$user_b@company.com"
    //     ]
    //   },
    //   "message": "请求成功",
    //   "result": true
    // }
    ....
} else {
    // 出错情况
    // 返回数据格式
    // {
    //   "statusCode": 40863,
    //   "info": {},
    //   "message": "to中有不存在的地址列表. 参数to: user_a@company.com",
    //   "result": false
    // }
    ....
}
....
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3564d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3401509?v=4)[许晓峰](/maintainers/chocoboxxf)[@chocoboxxf](https://github.com/chocoboxxf)

---

Top Contributors

[![chocoboxxf](https://avatars.githubusercontent.com/u/3401509?v=4)](https://github.com/chocoboxxf "chocoboxxf (3 commits)")

---

Tags

sdkmailsmsyii2sendcloud

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chocoboxxf-yii2-sendcloud-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/chocoboxxf-yii2-sendcloud-sdk/health.svg)](https://phpackages.com/packages/chocoboxxf-yii2-sendcloud-sdk)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NotifyX、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

687111.2k8](/packages/guanguans-notify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
