Download the PHP package mailengin/mailengin-php without Composer
On this page you can find all versions of the php package mailengin/mailengin-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mailengin/mailengin-php
More information about mailengin/mailengin-php
Files in mailengin/mailengin-php
Package mailengin-php
Short Description Official PHP SDK for the MailEngin Email API
License MIT
Homepage https://mailengin.app
Informations about the package mailengin-php
MailEngin PHP SDK
The official PHP SDK for sending transactional email through MailEngin. It provides typed request and response objects, Guzzle integration, configurable timeouts, and structured exceptions.
[!IMPORTANT] This package is for server-side applications only. Never expose a MailEngin API key in JavaScript, browser, mobile, or other client-distributed code.
Requirements
- PHP 8.2 or newer
- Composer 2
- A MailEngin API key and verified sending domain
Installation
Before You Send
- Verify a sending domain.
- Create an API key and save the full secret.
- Create and publish a Developer Template.
- Copy the template API name, such as
welcome-email.
Store the API key in your server's secret manager or environment:
MailEngin displays the full key only once. A masked key cannot authenticate requests.
Quick Start
The published template supplies the subject and HTML. Values in variables replace matching template variables such as {{first_name}}.
Send One Email
Send request fields
| Constructor argument | Type | Required | Description |
|---|---|---|---|
to |
string |
Yes | Recipient email address. |
templateName |
?string |
Recommended | Published template API name or exact display name. |
templateId |
?string |
No | Legacy template identifier. Prefer templateName. |
variables |
?array |
No | Values used to render template variables. |
subject |
?string |
Raw HTML only | Template subject override, or required subject for raw HTML. |
fromEmail |
?string |
Recommended | Sender on a verified domain authorized for the API key. |
html |
?string |
Advanced | Raw HTML used when no template is supplied. |
replyToMailEngin |
?bool |
No | Route recipient replies into the MailEngin inbox. |
Exactly one content source is required: templateName, templateId, or html. Raw HTML sends also require subject.
Send Personalized Bulk Email
Bulk requests support up to 1,000 recipients. Request-level variables apply to every recipient; recipient variables take precedence.
For the same content without recipient-specific variables, use strings:
A successful bulk response confirms that recipients were queued. It is not a guarantee that every message was delivered.
Send Raw HTML
Published templates are recommended for reusable product email. For a one-off message, provide both subject and html:
Sender Selection
MailEngin resolves the sender in this order:
fromEmailsupplied in the request.- Sender saved in the published Developer Template.
noreply@<authorized-domain>fallback.
The sender domain must be verified and authorized for the API key. Set the sender in the template or request for predictable production sends.
Error Handling
API, timeout, malformed-response, and network failures throw MailEnginError:
isRetryable() returns true for network errors, timeouts, HTTP 408, HTTP 429, and 5xx responses. The SDK never retries sends automatically because a retry could create a duplicate email until idempotency keys are supported.
Invalid local input, such as an empty recipient or raw HTML without a subject, throws InvalidArgumentException before an API request is made.
Configuration
| Constructor argument | Default | Description |
|---|---|---|
apiKey |
None | Full server-side MailEngin API key. |
baseUrl |
https://api.mailengin.app |
Override for local, test, or dedicated environments. |
timeout |
30.0 |
Request timeout in seconds. |
httpClient |
New Guzzle client | Injectable PSR-compatible ClientInterface implementation. |
Framework Integration
Create one client in your dependency-injection container and reuse it. For example, a Laravel service provider can register a singleton:
Configuration belongs in config/services.php, backed by MAILENGIN_API_KEY; do not commit the secret to source control.
Testing With an Injected Client
Use Guzzle's mock handler to test your integration without a real API key or network request:
Development
See PUBLISHING.md for maintainer release instructions.
Resources
- MailEngin API documentation
- Developer Templates
- API keys
- Security policy
- Changelog
License
Released under the MIT License. Copyright 2026 MailEngin.