A flexible WordPress email plugin with support for multiple mail service providers through a driver-based architecture.
Mailable allows you to send emails from WordPress using various email service providers (SendGrid, Mailpit, and more) through a unified, easy-to-use interface. Perfect for production environments and local development.
- Features
- Installation
- Quick Start
- Configuration
- Available Drivers
- Usage
- Developer Guide
- FAQ
- Support
- Changelog
- License
- 🚀 Multiple Email Providers - Support for SendGrid, Mailpit, and easily extensible for Mailgun, AWS SES, and more
- 🏗️ Driver-Based Architecture - Clean, extensible design that makes adding new providers simple
- 🧪 Development Tools - Built-in Mailpit support for local email testing without sending real emails
- 🎯 Unified Interface - Single settings page for all providers with dynamic form switching
- ✅ Connection Testing - Test your email configuration before sending
- 📧 Test Email Feature - Send test emails to verify everything works
- 🔒 Secure - Properly sanitizes and validates all inputs
- 🎨 Clean UI - Modern, intuitive WordPress admin interface
- Go to Plugins → Add New
- Search for "Mailable"
- Click Install Now
- Click Activate
- Download the plugin ZIP file
- Go to Plugins → Add New → Upload Plugin
- Choose the ZIP file and click Install Now
- Click Activate
wp plugin install mailable --activate-
Activate the Plugin
- Navigate to Settings → Mailable in your WordPress admin
-
Select Your Email Provider
- Choose from the available providers (SendGrid, Mailpit, etc.)
-
Configure Provider Settings
- Enter your provider-specific credentials
- For SendGrid: API key and verified sender email
- For Mailpit: Host and port (defaults work for most setups)
-
Test Your Configuration
- Click Test Connection to verify your settings
- Send a test email to confirm everything works
-
Save Settings
- Click Save Changes
- Your WordPress site will now send emails through your configured provider!
Mailable provides global settings that apply to all email providers:
- From Email - Default sender email address (optional, can be overridden by driver)
- From Name - Default sender name (optional, can be overridden by driver)
- Force "From" Settings - Recommended. Prevents other plugins from overriding your email headers
Each provider has its own configuration options. See the Available Drivers section for details.
Production-ready email delivery service
-
Get Your SendGrid API Key
- Sign up at SendGrid
- Go to Settings → API Keys
- Create a new API key with "Full Access" or "Mail Send" permissions
- Copy the API key (starts with
SG.)
-
Verify Your Sender
- Go to Settings → Sender Authentication
- Verify a sender email address or domain
-
Configure in WordPress
- Go to Settings → Mailable
- Select SendGrid as your provider
- Enter your API key
- Enter your verified sender email
- Optionally set a "From Name"
- Enable "Force From Settings" (recommended)
- SendGrid API Key (required) - Your SendGrid API key
- From Email (optional) - Verified sender email address
- From Name (optional) - Display name for emails
- Force "From" Settings (optional) - Override other plugins' email headers
Local email testing tool - perfect for development
-
Install Mailpit
# macOS (via Homebrew) brew install mailpit # Or download from https://github.com/axllent/mailpit/releases
-
Start Mailpit
mailpit
- SMTP server runs on
localhost:1025 - Web UI runs on
http://localhost:8025
- SMTP server runs on
-
Configure in WordPress
- Go to Settings → Mailable
- Select Mailpit (Development) as your provider
- Default settings (localhost:1025) work for most setups
- Adjust host/port if needed
-
View Emails
- Open
http://localhost:8025in your browser - All emails sent from WordPress will appear here
- Open
- SMTP Host (default:
localhost) - Mailpit SMTP host - SMTP Port (default:
1025) - Mailpit SMTP port - Use TLS/STARTTLS (optional) - Enable if your Mailpit uses encryption
- From Email (optional) - Default sender email for development
- From Name (optional) - Default sender name for development
- Force "From" Settings (optional) - Ensure consistent sender info
- ✅ No authentication required
- ✅ Works offline
- ✅ View all emails in a web interface
- ✅ Perfect for testing email templates
- ✅ No risk of sending test emails to real addresses
Once configured, Mailable works automatically with WordPress's built-in email functions:
// WordPress will use your configured provider
wp_mail(
'recipient@example.com',
'Subject',
'Message body',
array('Content-Type: text/html; charset=UTF-8')
);-
Test Connection
- Go to Settings → Mailable
- Scroll to Test Connection & Send Email
- Click Test Connection
- Verify the connection status
-
Send Test Email
- Enter your email address
- Click Send Test Email
- Check your inbox (or Mailpit UI if using Mailpit)
Mailable integrates with WordPress's email system, so all standard WordPress email hooks work:
// Modify email before sending
add_filter('wp_mail', function($args) {
// Modify $args['to'], $args['subject'], etc.
return $args;
});
// Modify email headers
add_filter('wp_mail_headers', function($headers) {
$headers[] = 'X-Custom-Header: value';
return $headers;
});Mailable uses a driver-based architecture, making it easy to add support for new email providers.
Create a new file: includes/drivers/class-{provider}-driver.php
<?php
/**
* Custom Provider Mail Driver
*
* @package Mailable
*/
if (!defined('ABSPATH')) {
exit;
}
class Custom_Provider_Driver extends Mail_Driver {
public function __construct() {
$this->driver_name = 'custom_provider';
$this->driver_label = 'Custom Provider';
}
public function configure_phpmailer($phpmailer) {
$api_key = $this->get_option('api_key');
$host = $this->get_option('host', 'smtp.customprovider.com');
$phpmailer->isSMTP();
$phpmailer->Host = $host;
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 587;
$phpmailer->Username = 'apikey';
$phpmailer->Password = $api_key;
$phpmailer->SMTPSecure = 'tls';
}
public function get_settings_fields() {
return array(
array(
'key' => 'api_key',
'label' => 'API Key',
'type' => 'password',
'required' => true,
'description' => 'Your Custom Provider API key.',
),
array(
'key' => 'host',
'label' => 'SMTP Host',
'type' => 'text',
'default' => 'smtp.customprovider.com',
'description' => 'SMTP server hostname.',
),
);
}
public function validate_config() {
$api_key = $this->get_option('api_key');
if (empty($api_key)) {
return new WP_Error('missing_api_key', 'API Key is required.');
}
return true;
}
public function test_connection() {
// Optional: Override for custom connection testing
$validation = $this->validate_config();
if (is_wp_error($validation)) {
return array(
'success' => false,
'message' => $validation->get_error_message(),
);
}
return array(
'success' => true,
'message' => 'Configuration is valid. Ready to send emails.',
);
}
}Option A: Register in Plugin
In mailable.php, add to the register_drivers() method:
require_once MAILABLE_PLUGIN_DIR . 'includes/drivers/class-custom-provider-driver.php';
Mail_Driver_Manager::register('custom_provider', 'Custom_Provider_Driver');Option B: Register via Hook (Recommended for Third-Party)
In your own plugin or theme:
add_action('mailable_register_drivers', function() {
require_once plugin_dir_path(__FILE__) . 'drivers/class-custom-provider-driver.php';
Mail_Driver_Manager::register('custom_provider', 'Custom_Provider_Driver');
});All drivers must extend Mail_Driver and implement:
| Method | Description | Required |
|---|---|---|
configure_phpmailer($phpmailer) |
Configure PHPMailer instance with provider settings | ✅ Yes |
get_settings_fields() |
Return array of settings field definitions | ✅ Yes |
validate_config() |
Validate driver configuration, return true or WP_Error |
✅ Yes |
test_connection() |
Test connection to provider (optional override) |
Supported field types:
text- Text inputemail- Email input with validationpassword- Password input (masked)textarea- Multi-line text inputcheckbox- Checkbox input
Field definition structure:
array(
'key' => 'field_key', // Required: Unique identifier
'label' => 'Field Label', // Required: Display label
'type' => 'text', // Required: Field type
'default' => 'default_value', // Optional: Default value
'required' => true, // Optional: Mark as required
'description' => 'Help text', // Optional: Description below field
'checkbox_label' => 'Checkbox text', // Optional: For checkbox fields
)mailable_register_drivers
Register custom drivers from other plugins or themes.
add_action('mailable_register_drivers', function() {
Mail_Driver_Manager::register('my_provider', 'My_Provider_Driver');
});Mailable integrates with WordPress's email system, so all standard WordPress email filters work:
wp_mail- Modify email arguments before sendingwp_mail_from- Modify sender emailwp_mail_from_name- Modify sender namewp_mail_headers- Modify email headersphpmailer_init- Modify PHPMailer instance (used by Mailable)
Mailable offers a clean, driver-based architecture that makes it easy to switch between providers or add custom ones. It's designed for both production use and local development with built-in Mailpit support.
No, Mailable uses one active provider at a time. You can easily switch between providers in the settings page.
Yes! Mailable integrates with WordPress's standard email system (wp_mail()), so any plugin that uses WordPress email functions will automatically use your configured provider.
Yes, Mailable works with WordPress multisite. Each site can have its own email provider configuration.
Yes, all settings are stored securely in WordPress's options table. API keys are stored as password fields and are never displayed in plain text.
Yes! Mailable is designed to be extensible. See the Developer Guide for instructions on adding custom drivers. You can also submit a feature request or contribute a driver.
Mailpit is designed for local development and testing. For production, use a proper email service like SendGrid, Mailgun, or AWS SES.
Mailable requires PHP 7.4 or higher.
- 📖 Documentation - Check this README and inline code comments
- 🐛 Bug Reports - Open an issue on GitHub
- 💡 Feature Requests - Submit via GitHub issues
- 💬 Questions - Use GitHub Discussions
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
When reporting bugs, please include:
- WordPress version
- PHP version
- Mailable version
- Steps to reproduce
- Error messages (if any)
- Screenshots (if applicable)
- ✨ Initial public release
- ✨ Driver-based architecture
- ✨ SendGrid driver
- ✨ Mailpit driver for development
- ✨ Connection testing
- ✨ Test email functionality
- ✨ Dynamic form switching
- ✨ Clean admin interface
This plugin is licensed under the GPL v2 or later.
Copyright (C) 2024 David Gaitan
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- Built with ❤️ for the WordPress community
- Uses PHPMailer for email delivery
- Inspired by Laravel's Mail driver architecture
Made with ❤️ by David Gaitan