Download the PHP package ez-php/mail without Composer
On this page you can find all versions of the php package ez-php/mail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mail
ez-php/mail
Transactional mail module for the ez-php framework. Delivers outgoing messages via a pluggable driver — SMTP (native PHP, no library required), Log (dev/CI), or Null (silent discard).
Installation
Quick Start
Register the provider in provider/modules.php:
Add config values to config/mail.php:
Send a message:
Drivers
| Driver | MAIL_DRIVER |
Description |
|---|---|---|
| SMTP | smtp |
Delivers via a real SMTP server (RFC 5321, pure PHP) |
| Mailgun | mailgun |
Mailgun v3 REST API via cURL; no third-party SDK |
| SendGrid | sendgrid |
SendGrid v3 Mail Send API via cURL; no third-party SDK |
| Log | log |
Writes a summary to a log file; safe for dev/CI |
| Null | null |
Silently discards every message (default) |
SMTP
Supports TLS via STARTTLS (port 587), implicit SSL (port 465), and plain-text (port 25).
Authentication is AUTH LOGIN; omit MAIL_USERNAME to skip authentication.
Mailgun
Delivers via the Mailgun HTTP API v3. US region uses api.mailgun.net; EU region uses api.eu.mailgun.net. Attachments are sent as multipart/form-data.
SendGrid
Delivers via the SendGrid v3 Mail Send API. Attachments are base64-encoded and sent inline in the JSON payload.
Log
When MAIL_LOG_PATH is empty, messages are written via error_log().
Mailable
Mailable is a fluent builder that can be used inline or extended per-message type:
Methods
| Method | Description |
|---|---|
to(string $address, string $name = '') |
Set recipient |
from(string $address, string $name = '') |
Override sender (uses driver default when not called) |
subject(string $subject) |
Set subject line |
text(string $body) |
Set plain-text body |
html(string $body) |
Set HTML body |
attach(string $path, string $name = '') |
Add file attachment |
Combining text() and html() produces a multipart/alternative message. Adding attachments wraps the content in multipart/mixed.
Static Facade
Mail::send(Mailable $mailable) delegates to the driver bound by MailServiceProvider.
In tests, inject a spy driver directly:
MIME Support
MimeBuilder constructs RFC 2822 / MIME messages internally. It handles:
text/plain(quoted-printable)text/html(quoted-printable)multipart/alternative(text + HTML)multipart/mixed(any of the above + attachments)- RFC 2047 encoding for non-ASCII subject lines and display names
- Base64-encoded attachments with MIME type detection via
mime_content_type()
Queue Integration
Mail delivery is synchronous by default — Mail::send() blocks until the driver finishes. To dispatch mail asynchronously, wrap the call in a queue job:
The Mailable is serialized with the job. Mail::send() inside handle() uses whatever driver is registered in the worker process — typically SmtpDriver in production and NullDriver or LogDriver in development.
Note: Queue-backed delivery is an application-layer concern. The
ez-php/mailpackage has no dependency onez-php/queue.
Local Development with Mailpit
Mailpit is a local SMTP mail catcher with a web UI. All outgoing mail is captured and displayed without being delivered to real recipients.
1 — Add Mailpit to docker-compose.yml
2 — Configure the SMTP driver to point at Mailpit
3 — Open the Mailpit web UI
Navigate to http://localhost:8025 in your browser. Every message sent via Mail::send() appears here instantly.
4 — SMTP integration tests
To run the Mailpit smoke tests in ez-php/mail itself:
The three Mailpit tests are skipped automatically when MAILPIT_HOST is not set.