Download the PHP package djagya/yii2-sparkpost without Composer

On this page you can find all versions of the php package djagya/yii2-sparkpost. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-sparkpost

SparkPost API Yii2 Mailer

SparkPost API Mailer for Yii2
Latest Stable Version Build Status Total Downloads License

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Set Up

To use SparkPost you will need to have a SparkPost Account.

They have a free Developer account that includes up to 15K messages/month, as well as a sandbox for ongoing development and testing with the same built-in features and performance as their paid plans, with no time limitation.

Once you have an account you will need to create an API Key.
You can create as many API keys as you want, and it's best practice to create one for each website.

For testing purposes, while you're waiting for domain verification, you can use a sandbox mode, which can be enabled in the extension's config.

Usage

To use this extension, add the following code in your application configuration (default cUrl http adapter will be used):

If you want to disable default "from" and "reply to" email address for messages you can set useDefaultEmail to false in Mailer config, but then you must specify "from" email address for every message you send.

Property retryLimit allows to make Mailer relatively failover. Mailer will try to send a transmission few times if it's getting an exception from Sparkpost, because sometimes Sparkpost API fails. When transmission send attempts count reaches specified retryLimit - last exception we got will be thrown. To disable that behavior and try to send transmission only once you can set retryLimit to 0.

Http Adapters

You can use different http adapters: cUrl (default), guzzle, etc. Full list is here: available adapters.
For detailed information refer to ivory-http-adapter.

To configure a http adapter that will be used by mailer you must specify httpAdapter attribute in the component configuration, you can use string, array or closure (BaseYii::createObject() is used to instantiate an adapter):

Send an email

You can then send an email as follows:

After email was sent few properties are filled with last transmission information:

Sandbox mode

To test email sending while your domain is not verified by Sparkpost you can use sandbox mode by setting sandbox option to true or use setSandbox directly for message.
Besides that you must set "from" email address to sandbox Sparkpost domain.

OR

Templates

Sparkpost templates are supported.
When you use a template, template's "from" and "subject" params will be used and override specified by you values.

To set message template and it's substitution data (template context) you should either give an array with specified template key and template data as a second param:

OR use setTemplateId() and setSubstitutionData() Message methods:

Besides that you can specify different set of template data, metadata, tags. You can specify these data for To, Cc, Bcc recipients. To do that you need to pass an array of addresses, where key is email and value is an array with specified metadata, tags and/or recipient name:

Unit Testing

You must have Codeception installed to be able to run unit tests.

To run tests:

If you want to try to send a real message, you should add APIKEY environment variable (it should be a real API key from SparkPost).
Example:

Logs

All mailer log messages are logged by \Yii::error(), \Yii::warning(), \Yii::info() under special category - sparkpost-mailer.

License

The code for yii2-sparkpost is distributed under the terms of the MIT license (see LICENSE).


All versions of yii2-sparkpost with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
yiisoft/yii2 Version *
sparkpost/sparkpost Version ~1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package djagya/yii2-sparkpost contains the following files

Loading the files please wait ....