├── .github ├── FUNDING.yml └── dependabot.yml ├── .editorconfig ├── src ├── SendCloud.php └── SendCloudServiceProvider.php ├── composer.json └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [overtrue] 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: composer 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "21:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = false 10 | 11 | [*.{vue,js,scss}] 12 | charset = utf-8 13 | indent_style = space 14 | indent_size = 2 15 | end_of_line = lf 16 | insert_final_newline = true 17 | trim_trailing_whitespace = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /src/SendCloud.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * This source file is subject to the MIT license that is bundled. 9 | */ 10 | 11 | namespace Overtrue\LaravelSendCloud; 12 | 13 | use Illuminate\Support\Facades\Facade; 14 | 15 | /** 16 | * Class SendCloud. 17 | * 18 | * @author overtrue 19 | */ 20 | class SendCloud extends Facade 21 | { 22 | public static function getFacadeAccessor() 23 | { 24 | return \Overtrue\SendCloud\SendCloud::class; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "overtrue/laravel-sendcloud", 3 | "description": "SendCloud SDK for Laravel.", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "overtrue", 8 | "email": "anzhengchao@gmail.com" 9 | } 10 | ], 11 | "require": { 12 | "overtrue/sendcloud": "^1.0", 13 | "laravel/framework": "^9.0|^10.0|^11.0" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "Overtrue\\LaravelSendCloud\\": "src" 18 | } 19 | }, 20 | "extra": { 21 | "laravel": { 22 | "providers": [ 23 | "Overtrue\\LaravelSendCloud\\SendCloudServiceProvider" 24 | ], 25 | "aliases": { 26 | "SendCloud": "Overtrue\\LaravelSendCloud\\SendCloud" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/SendCloudServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * This source file is subject to the MIT license that is bundled. 9 | */ 10 | 11 | namespace Overtrue\LaravelSendCloud; 12 | 13 | use Illuminate\Support\ServiceProvider; 14 | use Overtrue\SendCloud\SendCloud; 15 | 16 | /** 17 | * Class SendCloudServiceProvider. 18 | * 19 | * @author overtrue 20 | */ 21 | class SendCloudServiceProvider extends ServiceProvider 22 | { 23 | /** 24 | * Boot service. 25 | */ 26 | public function boot() 27 | { 28 | } 29 | 30 | /** 31 | * Register services. 32 | */ 33 | public function register() 34 | { 35 | $this->app->bind(SendCloud::class, function ($app) { 36 | $config = config('services.sendcloud', []); 37 | 38 | if (empty($config['api_user']) || empty($config['api_key'])) { 39 | throw new \RuntimeException('No sendcloud configuration found.'); 40 | } 41 | 42 | return new SendCloud($config['api_user'], $config['api_key'], $config); 43 | }); 44 | 45 | $this->app->alias(SendCloud::class, 'sendcloud'); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Laravel SendCloud 2 | 3 | SendCloud Mail SDK for Laravel. 4 | 5 | ![Laravel Octane Ready Status](https://img.shields.io/badge/Octance-ready-green?style=flat-square) 6 | ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/overtrue/laravel-sendcloud?style=flat-square) 7 | ![GitHub License](https://img.shields.io/github/license/overtrue/laravel-sendcloud?style=flat-square) 8 | ![Packagist Downloads](https://img.shields.io/packagist/dt/overtrue/laravel-sendcloud?style=flat-square) 9 | 10 | [![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue) 11 | 12 | ## Installing 13 | 14 | ```shell 15 | $ composer require overtrue/laravel-sendcloud -vvv 16 | ``` 17 | 18 | ## Usage 19 | 20 | 1. config your apiUser and apiKey into `config/services.php`: 21 | 22 | ```php 23 | //... 24 | 25 | 'sendcloud' => [ 26 | 'api_user' => env('SENDCLOUD_API_USER', ''), 27 | 'api_key' => env('SENDCLOUD_API_KEY', ''), 28 | ], 29 | ``` 30 | 31 | 2. Call SendCloud API: 32 | 33 | ```php 34 | $result = SendCloud::post('/mail/send', [ 35 | 'from' => 'demo@DKDJzmUzrxCESzdCu5R.sendcloud.org', 36 | 'to' => 'demo@easywechat.com', 37 | 'subject' => '来自 SendCloud 的第一封邮件!', 38 | 'html' => '你太棒了!你已成功的 从SendCloud 发送了一封测试邮件!', 39 | ]); 40 | 41 | // or 42 | 43 | $result = app('sendcloud')->get('addresslist/list'); 44 | ``` 45 | 46 | ## Documentation 47 | 48 | - [overtrue/sendcloud](https://github.com/overtrue/sendcloud) 49 | - [SendCloud Mail API v2](http://www.sendcloud.net/doc/email_v2/) 50 | 51 | 52 | ## :heart: Sponsor me 53 | 54 | [![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue) 55 | 56 | 如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue) 57 | 58 | 59 | ## Project supported by JetBrains 60 | 61 | Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects. 62 | 63 | [![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/overtrue) 64 | 65 | ## PHP 扩展包开发 66 | 67 | > 想知道如何从零开始构建 PHP 扩展包? 68 | > 69 | > 请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package) 70 | 71 | ## License 72 | 73 | MIT 74 | --------------------------------------------------------------------------------