wpdiggerstudio / wpzylos-mail
Fluent email abstraction for WPZylos Framework
Fund package maintenance!
v1.0.0
2026-06-14 08:19 UTC
Requires
- php: ^8.0
- wpdiggerstudio/wpzylos-core: ^1.0
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0
- squizlabs/php_codesniffer: ^3.0
- szepeviktor/phpstan-wordpress: ^1.0
This package is auto-updated.
Last update: 2026-06-14 11:48:22 UTC
README
Fluent email abstraction for WPZylos Framework — Build beautiful, responsive emails in WordPress with a clean, chainable API.
✨ Features
- 📝 Fluent Mailable Builder — Chainable API for building emails (to, cc, bcc, subject, html, text, view, line, greeting, action, attach)
- 📮 MailManager Service — Central mail service with configurable defaults
- 🎨 PHP Template Rendering — Render email bodies from PHP view templates
- 📱 Responsive HTML Layout — Built-in responsive email layout that works across clients
- 🔌 wp_mail() Integration — Full compatibility with WordPress SMTP plugins
- 📎 File Attachments — Attach files with a single method call
- ⚡ ServiceProvider — Drop-in container registration
📋 Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.0 |
| WordPress | 5.9+ |
| wpzylos-core | ^1.0 |
📦 Installation
composer require wpdiggerstudio/wpzylos-mail
🚀 Quick Start
Register the Service Provider
use WPZylos\Framework\Mail\MailServiceProvider; // In your plugin bootstrap $app->register(new MailServiceProvider());
Send Your First Email
use WPZylos\Framework\Mail\Mailable; $mail = new Mailable(); $mail->to('user@example.com') ->subject('Welcome!') ->greeting('Hello John!') ->line('Thanks for joining our platform.') ->action('Visit Dashboard', 'https://example.com/dashboard') ->line('We are happy to have you.') ->send();
📚 Core Features
Fluent Mailable Builder
Build emails step-by-step with a clean, chainable API:
use WPZylos\Framework\Mail\Mailable; $mail = new Mailable(); $mail->to('user@example.com') ->cc('manager@example.com') ->bcc('archive@example.com') ->from('noreply@example.com', 'My Plugin') ->replyTo('support@example.com') ->subject('Your Weekly Report') ->greeting('Hi Sarah!') ->line('Here is your weekly activity report.') ->line('You completed 12 tasks this week.') ->action('View Full Report', 'https://example.com/report') ->line('Keep up the great work!') ->attach('/path/to/report.pdf') ->send();
MailManager — Central Mail Service
Use MailManager for a centralized mailing experience with pre-configured defaults:
use WPZylos\Framework\Mail\MailManager; $mailManager = $app->make(MailManager::class); // Set global defaults $mailManager->setFrom('noreply@example.com', 'My Plugin'); // Send with defaults pre-applied $mailManager->to('user@example.com') ->subject('Order Confirmed') ->view('emails.order-confirmed', ['order' => $order]) ->attach('/path/to/invoice.pdf') ->send();
Raw HTML Emails
$mail = new Mailable(); $mail->to('user@example.com') ->subject('Custom HTML') ->html('<h1>Hello!</h1><p>This is a custom HTML email.</p>') ->send();
Plain Text Emails
$mail = new Mailable(); $mail->to('user@example.com') ->subject('Plain Text') ->text('Hello! This is a plain text email.') ->send();
PHP Template Rendering
Render emails from PHP view templates with data injection:
$mail = new Mailable(); $mail->to('user@example.com') ->subject('Invoice #1234') ->templatePath('/path/to/templates') ->view('invoice', [ 'customer' => $customer, 'items' => $items, 'total' => '$99.00', ]) ->send();
Custom Headers
$mail = new Mailable(); $mail->to('user@example.com') ->subject('Priority Message') ->header('X-Priority', '1') ->header('X-Mailer', 'WPZylos Mail') ->line('This is an important message.') ->send();
Building Without Sending
Inspect the email before sending:
$mail = new Mailable(); $mail->to('admin@example.com') ->subject('Test Email') ->greeting('Hello!') ->line('This is a test.'); $built = $mail->build(); // $built = [ // 'to' => ['admin@example.com'], // 'subject' => 'Test Email', // 'message' => '...html...', // 'headers' => ['Content-Type: text/html; charset=UTF-8'], // 'attachments' => [], // ]
📦 Related Packages
| Package | Description |
|---|---|
| wpzylos-notification | Multi-channel notification system |
| wpzylos-queue | Queue emails for asynchronous sending |
| wpzylos-views | View/template rendering engine |
📖 Documentation
Full documentation is available at wpzylos.com/docs/latest/packages/wpzylos-mail.
💬 Support
- 🐛 Bug Reports: GitHub Issues
- 💡 Feature Requests: GitHub Issues
- 📖 Documentation: wpzylos.com
Support the Project
📄 License
This package is open-sourced software licensed under the MIT License.
🤝 Contributing
Please see CONTRIBUTING.md for details on how to contribute.
Made with ❤️ by WPDiggerStudio