Download the PHP package baraja-core/emailer without Composer
On this page you can find all versions of the php package baraja-core/emailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download baraja-core/emailer
More information about baraja-core/emailer
Files in baraja-core/emailer
Package emailer
Short Description Automation tool for e-mail distribution, queue management and advanced logging.
License
Homepage https://github.com/baraja-core/emailer
Informations about the package emailer
Emailer
Automation tool for e-mail distribution, queue management and advanced logging for Nette Framework with Doctrine ORM.
Main Principles
- Queue-based delivery - E-mails are stored in database and sent asynchronously via daemon process
- Template rendering - Support for Latte, HTML and plain text templates with localization
- Retry mechanism - Failed e-mails are automatically retried up to 5 times with exponential backoff
- Logging & monitoring - Complete audit trail of all sent e-mails with timing metrics
- Garbage collection - Automatic cleanup of old logs and message bodies
- Recipient fixing - Automatic typo correction for common e-mail domains (gmail.com, seznam.cz, etc.)
Architecture
Main Components
| Component | Description |
|---|---|
Emailer |
Main service implementing Nette\Mail\Mailer interface. Handles sending e-mails directly or via queue. |
Message |
Extended Nette\Mail\Message with support for priority, scheduled sending and localization. |
QueueRunner |
Processes e-mail queue, handles retries and logs results. |
EmailerDaemon |
Symfony Console command for running queue processor as daemon. |
TemplateRenderer |
Renders e-mail templates using pluggable renderers (Latte, HTML, TXT). |
EmailerLogger |
Persists logs to database with INFO/WARNING/ERROR levels. |
GarbageCollector |
Cleans old logs and message bodies to keep database size manageable. |
Fixer |
Interface for e-mail address correction (typo fixing). |
Entity Structure
| Entity | Table | Purpose |
|---|---|---|
Email |
core__emailer_email |
Queue entry with status, attempts count, timing metrics |
Log |
core__emailer_log |
Log entries linked to e-mails |
Configuration |
- | Runtime configuration (not persisted) |
📦 Installation
It's best to use Composer for installation, and you can also find the package on Packagist and GitHub.
To install, simply use the command:
You can use the package manually by creating an instance of the internal classes, or register a DIC extension to link the services directly to the Nette Framework.
Requirements
- PHP 8.0+
- Nette Framework 3.0+
- Doctrine ORM
- Latte 2.5+
Configuration
Register the extension in your config.neon:
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
useQueue |
bool | true |
Enable queue mode (recommended for production) |
defaultFrom |
string | - | Default sender address |
adminEmails |
array | [] |
Admin e-mails for system notifications |
mail |
array | - | SMTP configuration (same as Nette mailer) |
Basic Usage
Sending Simple E-mail
Sending Urgent E-mail (Bypasses Queue)
Using E-mail Service Classes
Create a reusable e-mail service by extending BaseEmail:
Then send it:
Scheduled Sending
Sending to Administrators
Running the Daemon
Set up a cron job to run the e-mail daemon:
The daemon will:
- Process queued e-mails for ~5 minutes (configurable timeout)
- Handle retries for failed e-mails
- Run garbage collection after processing
Queue Configuration
Adjust queue behavior via Configuration entity:
| Setting | Default | Description |
|---|---|---|
queueTimeout |
295s | How long daemon runs before exiting |
queueEmailDelay |
0.3s | Delay between sending e-mails |
queueCheckIterationDelay |
2s | Delay when queue is empty |
maxAllowedAttempts |
5 | Max retry attempts before marking as failed |
Template Rendering
Supported Formats
| Format | Extension | Renderer |
|---|---|---|
| Latte | .latte |
LatteRenderer |
| HTML | .html |
HtmlRenderer |
| Plain Text | .txt |
TextRenderer |
Latte Template Example
Translation Support
Use {_} tags for translations:
Custom Renderers
Implement Renderer interface and tag it:
E-mail Statuses
| Status | Description |
|---|---|
in-queue |
Waiting to be sent |
not-ready-to-queue |
Scheduled for future |
waiting-for-next-attempt |
Failed, will retry |
sent |
Successfully delivered |
preparing-error |
Template/build error |
sending-error |
SMTP/delivery error |
Custom Recipient Fixer
Implement Fixer interface to customize e-mail correction:
Register in DI container and it will be used automatically.
Logging
All e-mail operations are logged with three severity levels:
INFO- Successful operationsWARNING- Non-critical issuesERROR- Failed operations
Logs are automatically cleaned up:
- Common logs: after 14 days
- E-mail-related logs: after 3 months
- Message bodies: after 3 months
Author
Jan Barasek (https://baraja.cz)
📄 License
baraja-core/emailer is licensed under the MIT license. See the LICENSE file for more details.
All versions of emailer with dependencies
nette/mail Version ^3.0
nette/utils Version ^3.0
latte/latte Version ^2.5
baraja-core/localization Version ^2.0
baraja-core/dynamic-configuration Version ^2.0
baraja-core/html-to-text Version ^2.0
baraja-core/doctrine-mail-message Version ^2.0
baraja-core/network Version ^1.0