PHPackages                             huying/sms - 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. huying/sms

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

huying/sms
==========

提供发送短信的接口

48851[1 PRs](https://github.com/echo58/sms/pulls)PHP

Since Nov 17Pushed 9y ago1 watchersCompare

[ Source](https://github.com/echo58/sms)[ Packagist](https://packagist.org/packages/huying/sms)[ RSS](/packages/huying-sms/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

短信发送接口包
=======

[](#短信发送接口包)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2c0cb3943b441e3e842403687d5de44e95178f48c1b307c8f967cd347c912e7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f687579696e672f736d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/huying/sms)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/569e76b58ad7d2c03c648b9d8b5b72a24760fe7022a46c665e7aeb9c94af76ed/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6563686f35382f736d732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/echo58/sms)[![Coverage Status](https://camo.githubusercontent.com/bafbd0e1d8170eb1fa3ffb3465b284e9aeeb02f56d8862105d008b67fb204c99/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6563686f35382f736d732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/echo58/sms/code-structure)[![Quality Score](https://camo.githubusercontent.com/0ba517459f4d66c3485de210bed8a4c2a91e9db466da0d9e888f24b2d5bc0447/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6563686f35382f736d732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/echo58/sms)[![Total Downloads](https://camo.githubusercontent.com/9d033c9b63c2c64b4b509ccbc1cb029d8c592c253252ca96ccd0d36fb00167dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f687579696e672f736d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/huying/sms)

本包对常见的短信发送功能进行了抽象，包含了短信发送这一功能实现过程中需要用到的类，使得具体实现某一平台的短信发送功能异常简单。

安装
--

[](#安装)

### 短信包开发者

[](#短信包开发者)

通过 Composer 安装

```
$ composer require huying/sms
```

### 短信包使用者

[](#短信包使用者)

直接安装对应短信平台的包即可，不需要直接安装本包，目前支持的短信平台如下：

- 容联云通讯
- 云片网络

使用方法
----

[](#使用方法)

### 实例化短信平台类

[](#实例化短信平台类)

```
$provider = new Huying\Sms\\Provider([
    'accountSid' => 'xxxxx',
    'authToken' => 'xxxxx',
    'appId' => 'xxxxxx',
]);
```

实例化时需要传给构造函数的参数在不同短信平台下一般是不一样的，具体请见相应平台的包。

### 直接发送短信

[](#直接发送短信)

```
$message = Message::create()
    ->setRecipient('18800000000')
    ->setBody('我是短信内容')
    ->using($provider)
    ->send();
```

### 判断短信是否发送成功

[](#判断短信是否发送成功)

```
if ($message->getStatus() == Huying\Sms\MessageStatus::STATUS_SENT) {
    echo '发送成功';
} else {
    echo '发送失败:错误码'.$message->getError()->getCode()
        .',错误消息:'.$message->getError()->getMessage();
}
```

### 短信池

[](#短信池)

短信池中可以放入多条短信，然后一次发送

```
$pool = Pool::create([$provider]);
$pool->addMessage($message1);
$pool->addMessage($message2);
$pool->send();
```

短信池支持设置多个平台的provider，发送短信池中短信时，会按照provider的优先级逐一尝试，直到发送成功为止

```
$pool = Pool::create([$provider1, $provider2]);
```

更新日志
----

[](#更新日志)

请访问 [更新日志](CHANGELOG.md) 查看有关该项目的更新信息。

贡献代码
----

[](#贡献代码)

请查看 [贡献指南](CONTRIBUTING.md)。

开发者
---

[](#开发者)

- [Xujian Chen](https://github.com/xjchengo)
- [所有贡献者](../../contributors)

许可协议
----

[](#许可协议)

本项目使用 MIT 协议，详情请查看 [License File](LICENSE.md)。

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/812e4f96e9fc673af1ec2b1ad4536369021d54492cc970e9f408b26e4dee3bf4?d=identicon)[xjchengo](/maintainers/xjchengo)

---

Top Contributors

[![xjchengo](https://avatars.githubusercontent.com/u/4819996?v=4)](https://github.com/xjchengo "xjchengo (8 commits)")

### Embed Badge

![Health badge](/badges/huying-sms/health.svg)

```
[![Health](https://phpackages.com/badges/huying-sms/health.svg)](https://phpackages.com/packages/huying-sms)
```

###  Alternatives

[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[eduardokum/laravel-mail-auto-embed

Library for embed images in emails automatically

1702.0M5](/packages/eduardokum-laravel-mail-auto-embed)

PHPackages © 2026

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