Git Product home page Git Product logo

yii2-sendcloud's Introduction

SendCloud Yii2 integration

中文文档

This extension allows developpers to use SendCloud as an email transport. Also, you may use this extension to send SMS messages to Chinese cell phones via SendCloud. This work is inspired by yii2-sendgrid.

Installation

If you use Composer, you can update your composer.json like this :

{
    "require": {
        "softbread/yii2-sendcloud": "@dev"
    }
}

How to use it

Add extension to your configuration

return [
    //....
    'components' => [
        'mailer' => [
            'class' => 'SendCloud\Mail\Mailer',
            'api_user' => '<your sendcloud api-user>',
            'api_key'  => '<your sendcloud api-key>'
        ],
        'sendSms' => [
            'class'  => 'SendCloud\Sms\SendSms',
            'apiUser => '<your SMS api-user>',
            'apiKey  => '<your SMS api-key>'
        ],
    ],
];

You can send email via SendCloud as mailer component

Yii::$app->mailer->compose('contact/html')
     ->setFrom('[email protected]')
     ->setTo($form->email)
     ->setSubject($form->subject)
     ->send();

For further instructions refer to the related section in the Yii Definitive Guide

Also you can use SendCloud template Emails

Yii::$app->mailer->compose('contact/html')
     ->setFrom('[email protected]')
     ->setTo([email1, email2])
     ->setSubject($form->subject)
     ->setTemplateName('revoke-name')
     ->setTemplateVars([
            '%name%' => ['X1', 'X2'],
            '%money%'=> [12.5, 1.9]
        ])
     ->send();

To send SMS message:

Yii::$app->sendSms->setTo(['13700000000', '13011111111'])
    ->setTemplate('1001')
    ->setVars(['code' => '000111'])
    ->send();

For further instruction refer to the SendCloud SMS API doc

yii2-sendcloud's People

Contributors

softbread avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.