rubenbuijs/mailcoach-api-wrapper

API wrapper to connect with a standalone Mailcoach server.

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/rubenbuijs/mailcoach-api-wrapper

dev-main 2021-10-30 20:00 UTC

This package is auto-updated.

Last update: 2025-12-29 03:34:14 UTC


README

This is an API wrapper for Spatie's Mailcoach. Use this package when you have installed Mailcoach on a standalone server - separate from your app. I favored the standalone instance because it reduced dependencies in my apps.

Installation

A prerequisite is that you have installed Mailcoach as a standalone app.

You can install this package via composer:

composer require rubenbuijs/mailcoach-api-wrapper

Configuration

MAILCOACH_API_BASE_URL=https://yourdomain.com/api
MAILCOACH_API_TOKEN=1|XXXXXXXXXXXXXXXXXXXXXXX # Mailcoach installation: Config->API Tokens
MAILCOACH_LIST_ID=1
MAILCOACH_SSL=false

Usage

After installation, the Newsletter class is available to interact with your Mailcoach server.

Subscribe a new person

Newsletter::subscribe(string $email, string $name, array $tags = [])

Update a subscriber

Enter NULL when you don't want to make changes to the email, name, or tags.

Newsletter::update(string $email, string $new_email = null, string $name = null, array $tags = null)

Add tag(s)

Newsletter::addTags(string $email, array $tags_to_add)

Delete tag(s)

Newsletter::deleteTags(string $email, array $tags_to_delete)

Retrieve subscriber data

Newsletter::getSubscriberByEmail(string $email)

Enjoyed this package?

Take a look at my products:

  • Boei: Website Lead, Communication & Social widget
  • ProductLift: World’s most flexible prioritization, roadmap, and changelog tool.