Download the PHP package leeovery/mailcoach-api without Composer

On this page you can find all versions of the php package leeovery/mailcoach-api. 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 mailcoach-api

Mailcoach API

This is an opinionated API add-on to Spatie's Mailcoach app.

It provides a limited set of endpoints for managing Mailcoach over an API. It also provides some UI for managing your API clients for auth, and webhook management.

Installation

To use this package you should first purchase and install Mailcoach from Spatie into a new or existing Laravel app. Alternatively you can install the Mailcoach standalone app.

Once that's done you can install this package alongside Mailcoach.

You can install the package via composer:

Prepare Database:

Publish migrations...

... & migrate.

Add Route Macro

Add the following line to your RouteServiceProvider map method:

The params passed in are the defaults so if you're happy with those then feel free to leave them out. On the other hand, you need to change the prefix, you can do so by changing what you pass into the macro.

Publish Views:

Publish Config:

In the config file that's published you can edit the middleware for both the web routes and the api routes.

You can also setup the webhook secret in this file. I recommend using an env var to set this up and keep it secret as it ensures your webhook endpoint(s) stay secure.

Setup Auth

Setup Laravel Passport for machine-to-machine auth, as per the Passport instructions:

If you should now be able to see the new menu options in Mailcoach, namely API Clients & Webhooks.

To allow access using the API you will need to create yourself a new API Client. Once that's done you will then have a ClientID (which is an int) and a Client Secret. Both of these will be required to authenticate with the API.

To get actual access to the API from your client you will need to obtain an access_token. To do this, from the client app you will need to do a POST request to [your-api-url]/api/oauth/token with the following post body:

This should be obtained prior to each API session / request, as they don't last forever.

To get an idea you can run the following in your terminal to get the access_token:

Usage

Consider...

This API makes a few assumptions which are important to understand.

The main one is that it considers a subscriber of a certain email, no matter which list they are on, to be the same person. Mailcoach has the concept that each Subscriber belongs to one EmailLst. A person can subscribe to multiple lists, but that will result in multiple Subscriber records being created for them.

This package introduces a Contact entity, which will group Subscriber records, based on the email, and will keep the email, names, and other meta info consolidated across all their Subscriber records.

Example:

Consider the user [email protected] is subscribed to 2 lists, and unsubscrbed from 1...

A GET request to /contact/[email protected] would result in the following response data:

The important thing to take away from this, is that if you want to keep Subscriber records of the same email address independent across EmailLists, you might need to fork this package and make some changes. Or do a PR and let's chat :)

Endpoints

This package provides a limited number of endpoints, which you can easily see by running php artisan route:list from the app dir in your terminal.

But in a nutshell it provides:

GET /list

GET /contact/{email}

PATCH /contact

POST /campaign

Webhooks

We use the awesome Laravel Webhook Server for provide webhook support.

If you want to change some of the defaults, you can publish teh config file from that package and tweak away. This package simply uses the defaults so anything you change will take effect.

To receive the webhooks this package dispatches you should use the matching client package: Laravel Webhook Client.

Get Familiar:

Easiest way to get familiar with this is to check webhook the UI. Go ahead and create a new Webhook and you will see how it works.

Essentially, any time a Mailcoach event occurs, we will intercept it, check if any webhooks are configured for that event, and if so, go ahead and fire them.

This way your client app can be notified when a subscriber unsubscribes, or marks an email you send as spam etc.

On the whole, anything triggered via the API wont result in a webhook being fired. The exception to this is sending a campaign via the API - that will trigger events and therefore webhooks. However, updating contacts usually won't - unless I missed something. To be safe, it would be wise to code an awareness for the potential of feedback loops when using the API and webhooks.

Final note:

If you're unsure of how this will work for you, the best thing to do is check the code.

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of mailcoach-api with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
illuminate/support Version ^7.0
laravel/passport Version ^8.3
spatie/data-transfer-object Version ^1.13
spatie/laravel-mailcoach Version ^2.0.0
spatie/laravel-webhook-server Version ^1.5
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 leeovery/mailcoach-api contains the following files

Loading the files please wait ....