Configuration
MailManager Defaults
Default From Address
MailManager resolves the "from" address in this order:
- Explicitly set via
from()on theMailable(overrides MailManager default) - Default set via
setFrom()on theMailManager(applied when creating mailables) - Falls back to
get_option('admin_email')andget_option('blogname')
$mailManager = $app->make(MailManager::class);
// Set default from for all emails
$mailManager->setFrom('[email protected]', 'My Plugin');
Default Template Path
When MailManager creates a Mailable, it automatically sets the template path to your plugin's resources/mail directory (if the directory exists).
your-plugin/
+-- resources/
| +-- mail/
| +-- welcome.php
| +-- invoice.php
| +-- notification.php
+-- ...
Usage:
// Automatically resolves to {plugin_path}/resources/mail/welcome.php
$mailManager->to('[email protected]')
->subject('Welcome')
->view('welcome', ['name' => 'John'])
->send();
Custom Template Path
Override the template path per-mailable:
$mail = new Mailable();
$mail->templatePath('/custom/path/to/templates')
->view('my-template', $data);
SMTP Configuration
WPZylos Mail delegates transport to wp_mail(). SMTP settings are configured through WordPress or an SMTP plugin — there are no SMTP-specific settings in this package.
Recommended SMTP Plugins
| Plugin | Description |
|---|---|
| WP Mail SMTP | Most popular, supports Gmail, Outlook, SendGrid, etc. |
| FluentSMTP | Free, supports Amazon SES, Gmail, Outlook, etc. |
| Post SMTP | Feature-rich, includes email logging |
WordPress Hooks
WPZylos Mail uses wp_mail(), so all standard WordPress mail hooks apply:
wp_mail_from
Filter the from email address:
add_filter('wp_mail_from', function (string $email): string {
return '[email protected]';
});
wp_mail_from_name
Filter the from name:
add_filter('wp_mail_from_name', function (string $name): string {
return 'My Plugin';
});
wp_mail_content_type
Filter the content type:
add_filter('wp_mail_content_type', function (): string {
return 'text/html';
});
wp_mail
Filter all wp_mail() arguments:
add_filter('wp_mail', function (array $args): array {
// Modify $args['to'], $args['subject'], etc.
return $args;
});
Email Layout Customization
The built-in HTML layout (used by component body) provides:
- Centered 600px card layout
- White background with subtle shadow
- System font stack for cross-client compatibility
- Responsive design
To customize the layout, use html() with your own HTML or view() with a custom template instead of the component-based body.