Download the PHP package spatie/laravel-mailcoach-sdk without Composer
On this page you can find all versions of the php package spatie/laravel-mailcoach-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spatie/laravel-mailcoach-sdk
More information about spatie/laravel-mailcoach-sdk
Files in spatie/laravel-mailcoach-sdk
Package laravel-mailcoach-sdk
Short Description An SDK to easily work with the Mailcoach API in Laravel apps
License MIT
Homepage https://github.com/spatie/laravel-mailcoach-sdk
Informations about the package laravel-mailcoach-sdk
An SDK to easily work with the Mailcoach API in Laravel apps
This package contains the PHP SDK to work with Mailcoach. Both self-hosted (v6 and up) and hosted Mailcoach (aka Mailcoach Cloud) are supported. Using this package you can manage email lists, subscribers and campaigns.
Here are a few examples:
By default, Mailcoach' endpoints will are paginated with a limit of 1000. The package makes it easy to work with paginated resources. Just call ->next()
to get the next page.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
You must publish the config file with:
This is the contents of the published config file:
In your .env
file you should add the entries from the config file mentioned above. You'll find both the API token and endpoint on Mailcoach' API tokens screen in the Mailcoach settings.
Usage
You can use the Spatie\MailcoachSdk\Facades\Mailcoach
facade to perform most operations.
Handling pagination
There are several methods, such as emailLists()
, 'subscribers()' and campaigns()
to will return paginated results. To get the next page of results just call next()
on a result. If there are no more results, that method returns null
.
Here's how you display the email addresses of every subscriber on a list
On paginated results, $subscribers
in the example above there are also some more convenience methods:
results()
: get the results. A results object is also iterable, so you can also get to the results by simply using the object in a loopnext()
: fetch the next page of resultsprevious()
: fetch the previous page of resultscurrentPage()
: get the current page numbertotal()
: get the total number of results across all pagesnextUrl()
: get the URL that will be called to get the next page of resultspreviousUrl()
: get the URL that will be called to get the previous page of results
Working with email lists
Here's how to get all email lists:
You can get a single email list:
This is how you can create an email list:
You can get properties of email list:
Take a look at the source code of Spatie\MailcoachSdk\Resources\EmailList
to see the list of available properties.
You can update an email list by change one of the properties and calling save()
.
You can delete an email list by calling delete()
.
Working with subscribers
To get all subscribers of a list, you can call subscribers()
on an email list.
Optionally, you can pass filters to subscribers()
. Here how to get all subscribers with a Gmail-address.
Alternatively, you can call subscribers()
on $mailcoach
There's also a convenience method to quickly get a subscriber from a list.
Alternatively, you can get a subscriber by its UUID:
This how you can create a subscriber:
You can get properties of a subscriber:
Take a look at the source code of Spatie\MailcoachSdk\Resources\Subscriber
to see the list of available properties.
You can update a subscriber by change one of the properties and calling save()
.
You can confirm, unsubscribe and delete a subscriber by calling these methods.
Working with campaigns
Here's how to get all campaigns.
You can also get a single campaign();
This is how you can create a campaign:
You can get properties of a campaign:
Take a look at the source code of Spatie\MailcoachSdk\Resources\Campaign
to see the list of available properties.
You can update a campaign by change one of the properties and calling save()
.
A test mail will be sent when calling sendTest()
:
The campaign will be sent to all subscribers of your list, by calling send()
:
A campaign can be deleted:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Freek Van der Herten
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-mailcoach-sdk with dependencies
guzzlehttp/guzzle Version ^6.0|^7.5
illuminate/contracts Version ^9.0|^10.0|^11.0
spatie/laravel-package-tools Version ^1.13.0
spatie/mailcoach-sdk-php Version ^1.0