Download the PHP package myth/courier without Composer
On this page you can find all versions of the php package myth/courier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package courier
Short Description A CodeIgniter 4 package
License MIT
Informations about the package courier
myth/courier
Email campaigns and drip sequences for CodeIgniter 4.
- Blast campaigns — send a one-time email to a segment, tag-filtered audience, or all contacts
- Drip sequences — multi-step automated email sequences with configurable delays between steps
- Contact management — subscribe/unsubscribe, status tracking, tags, and custom fields
- Audience segmentation — target contacts by segment or tag
- Email tracking — open pixels, click-wrapped links, bounce and complaint logging
- CLI automation — spark commands for scheduled delivery and drip processing
Requirements
- PHP 8.2+
- CodeIgniter 4.7+
Installation
Run the package migrations:
Register tracking routes
The package ships a Config/Routes.php that registers the tracking endpoints automatically via CI4's module discovery. Enable it by adding 'routes' to your app/Config/Modules.php:
That's it — the following routes are then available with no further configuration:
| Route | Purpose |
|---|---|
GET /courier/open/{token} |
Open-tracking pixel (returns 1×1 GIF) |
GET /courier/click/{token} |
Click redirect (tracks click, redirects to target URL) |
GET /courier/unsubscribe/{token} |
One-click unsubscribe |
POST /courier/capture |
Signup form capture (used by courier_form()) |
Custom prefix or manual control: If you want a different URL prefix or to disable the routes entirely, keep 'routes' out of $aliases and add the group yourself in app/Config/Routes.php:
Configuration
Publish the config file:
Edit app/Config/Courier.php:
| Property | Type | Default | Description |
|---|---|---|---|
$fromName |
string |
'' |
Default sender display name |
$fromEmail |
string |
'' |
Default sender address |
$defaultLayout |
string |
bundled default | CI4 view path for the email wrapper layout |
$trackingHost |
string |
'' |
Custom tracking domain (e.g. https://track.yoursite.com); leave empty to use base_url() |
$batchSize |
int |
200 |
Max emails sent per CLI run |
$throttleMs |
int |
0 |
Milliseconds to sleep between individual sends (0 = no throttle) |
$testMode |
bool |
false |
When true, logs emails instead of sending them |
Quick Start
Subscribe a contact
Send a blast campaign
Set up a drip sequence
Segmentation
Courier supports two audience targeting strategies.
Tag filtering
Tag-filter campaigns send to all contacts who have ALL of the specified tags:
Segment rules
Segments let you save reusable audience definitions. The rules column is a JSON array of conditions matched against contact fields:
match_mode controls whether all rules must match (AND) or any rule may match (OR).
Create segments via SegmentService:
Template Authoring
Email templates are standard CI4 views. The view path is stored on each campaign or drip step and resolved via TemplateService::render().
Available variables
Inside a campaign body view:
| Variable | Description |
|---|---|
$contact |
ContactDTO — email, first_name, last_name, custom_fields, etc. |
$campaign |
CampaignDTO — name, subject, from_name, from_email |
$unsubscribeUrl |
Pre-generated one-click unsubscribe URL |
Inside a layout view:
| Variable | Description |
|---|---|
$content |
The rendered body view HTML |
$contact |
Same ContactDTO as above |
$campaign |
Same CampaignDTO as above |
$unsubscribeUrl |
One-click unsubscribe URL |
Example body view
Bundled views
The package ships with example templates under src/Views/courier/emails/ and a default layout under src/Views/courier/layouts/default.php. Copy and adapt them as starting points.
Tracking
The three tracking endpoints are registered under the /courier/ route group. Routes are auto-discoverable — see Register tracking routes for setup.
| Endpoint | Behavior |
|---|---|
GET /courier/open/{token} |
Records an open event; returns a 1×1 transparent GIF. Always returns the GIF — never 404 — so broken pixels stay silent in email clients. |
GET /courier/click/{token}?url={encoded-url} |
Records a click event (stores URL + client IP) and redirects to the target URL. Validates that the URL starts with http:// or https:// to prevent open-redirect abuse. |
GET /courier/unsubscribe/{token} |
Calls ContactService::unsubscribeByToken() and renders a confirmation page. Returns 404 for unknown tokens. |
Click tracking is injected automatically when MailerService sends: every href in the email body is rewritten through the click endpoint.
The unsubscribe URL is injected as the $unsubscribeUrl template variable automatically.
Scheduled Tasks
Run these on a cron schedule to process campaigns and drip steps automatically.
| Command | What it does | Recommended schedule |
|---|---|---|
courier:send-campaign |
Sends all blast campaigns that are in scheduled status and past their scheduled_at time. Accepts an optional campaign ID to process a single campaign. |
Every minute |
courier:process-drips |
Sends one batch of due drip steps ($batchSize emails). |
Every minute |
courier:track-events |
Stub for processing bounce webhooks or SMTP feedback loops. Does nothing by default — extend to add real handling. | As needed |
Example crontab:
Extending — Bounce Webhook Handler
To process bounces from your email provider's webhook, extend TrackEvents:
Project Structure
Running Tests
Code Quality
Docker
Documentation (MkDocs)
Docs live in docs/ and are built with Material for MkDocs.
License
MIT — see LICENSE.
All versions of courier with dependencies
league/commonmark Version ^2.0
myth/postal Version ^1.0@beta
symfony/yaml Version ^7.4