Skip to content

liewcf/enjinmel-smtp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnjinMel SMTP

WordPress Compatibility PHP Version License Version

Replace WordPress's default email sending with the Enginemailer REST API for improved deliverability and reliability.

Latest Release (v0.2.5): WordPress 7.0 compatibility release that restores legacy EngineMail upgrade paths, hardens test-email validation, and aligns the WordPress test stack. Release Notes | Download

Important: This plugin is an independent WordPress integration and is not affiliated with or endorsed by Enginemailer.

Understanding the Names

  • EnjinMel SMTP - The name of this WordPress plugin
  • Enginemailer - The third-party email delivery API service (https://enginemailer.com)

This plugin connects your WordPress site to the Enginemailer service API.

Features

  • Seamless Integration - Automatically intercepts all wp_mail() calls
  • Enhanced Deliverability - Routes emails through Enginemailer's reliable infrastructure
  • Comprehensive Logging - Track all email sends with timestamps, recipients, and status
  • Test Email Functionality - Verify configuration by sending test emails
  • Secure Storage - API keys encrypted using AES-256-CBC encryption
  • Log Management - Automatic log retention with configurable cleanup schedules
  • Admin Interface - User-friendly settings page with advanced log viewer
  • Export Capability - Export logs to CSV for analysis
  • Security First - Nonce verification, input sanitization, output escaping throughout

Requirements

Installation

Via WordPress Admin

  1. Download the latest release from the plugin repository
  2. Navigate to Plugins → Add New → Upload Plugin
  3. Choose the downloaded ZIP file and click Install Now
  4. Click Activate Plugin
  5. Go to EnjinMel SMTP → Settings to configure your API key

Manual Installation

  1. Upload the enjinmel-smtp folder to /wp-content/plugins/
  2. Activate the plugin through the Plugins menu in WordPress
  3. Configure the plugin via EnjinMel SMTP → Settings

Configuration

Basic Setup

  1. Navigate to EnjinMel SMTP → Settings
  2. Enter your Enginemailer API Key
  3. Set your default From Name and From Email
  4. Click Save Changes
  5. Use the Send Test Email feature to verify everything works

Advanced Configuration (Optional)

For enhanced security in shared hosting or high-security environments, add these constants to your wp-config.php:

// Custom encryption keys (recommended for production)
define('ENJINMEL_SMTP_KEY', 'your-32-character-encryption-key');
define('ENJINMEL_SMTP_IV', 'your-16-character-iv');

Generate secure keys using:

// Generate encryption key
echo bin2hex(random_bytes(16)); // 32 characters

// Generate IV
echo bin2hex(random_bytes(8));  // 16 characters

If these constants are not defined, the plugin will auto-generate and store encryption keys in the database.

Settings Options

  • API Key - Your Enginemailer API key (encrypted before storage)
  • Sender Name - Default sender name for outgoing emails
  • Sender Email - Default sender email address
  • Template ID - Optional Enginemailer template ID
  • Campaign Name - Optional campaign identifier for tracking
  • Force Sender - Override sender details set by other plugins
  • Enable Logging - Toggle email logging (enabled by default)

Usage

Once configured, the plugin automatically handles all WordPress emails. No code changes needed!

Programmatic Email Sending

// Standard wp_mail() - automatically uses EnjinMel SMTP
wp_mail(
    'recipient@example.com',
    'Subject Line',
    'Email message content',
    ['Content-Type: text/html; charset=UTF-8']
);

// With attachments
wp_mail(
    'recipient@example.com',
    'Subject with Attachment',
    'Message content',
    [],
    ['/path/to/attachment.pdf']
);

Hooks & Filters

The plugin provides numerous hooks for customization:

// Modify API payload before sending
add_filter('enjinmel_smtp_payload', function($payload, $normalized, $settings) {
    $payload['CustomField'] = 'value';
    return $payload;
}, 10, 3);

// Modify request timeout (default: 15 seconds)
add_filter('enjinmel_smtp_request_timeout', function($timeout) {
    return 30;
});

// Modify log retention (default: 90 days)
add_filter('enjinmel_smtp_retention_days', function($days) {
    return 30;
});

// Before email send
add_action('enjinmel_smtp_before_send', function($normalized, $payload) {
    // Custom logic before API call
}, 10, 2);

// After email send
add_action('enjinmel_smtp_after_send', function($normalized, $payload, $result) {
    // Custom logic after API call
}, 10, 3);

Log Viewer

Access comprehensive email logs at EnjinMel SMTP → Email Logs:

  • Filter by status (sent/failed)
  • Search by recipient or subject
  • Date range filtering
  • Export to CSV
  • Bulk delete operations
  • Pagination with configurable items per page

Development

Local Development Setup

# Clone the repository
git clone <repository-url>
cd enjinmel-smtp

# Install dependencies
composer install

# Start WordPress environment (requires @wordpress/env)
npx wp-env start

Running Tests

# Run PHPUnit tests
vendor/bin/phpunit

# Using wp-env (if configured)
npx wp-env run tests-cli phpunit

# Check code standards
vendor/bin/phpcs

# Fix code standards automatically
vendor/bin/phpcbf

Development Commands

# Create new feature branch with spec
bash scripts/create-new-feature.sh "feature description"

# Get active feature paths
bash scripts/get-feature-paths.sh

# Build a lean distribution zip (excludes tests/docs/dev files)
mkdir -p dist
git archive --format=zip --output dist/enjinmel-smtp.zip --worktree-attributes HEAD

Code Standards

  • Follows WordPress Coding Standards
  • PHP 7.4+ compatibility
  • PSR-4 autoloading (via Composer)
  • Comprehensive PHPDoc comments
  • Security-first approach

Security

Security Features

  • Encrypted Storage - API keys encrypted with AES-256-CBC
  • Nonce Protection - All admin actions verified with WordPress nonces
  • Capability Checks - manage_options capability required for all admin functions
  • Input Sanitization - All user inputs sanitized before processing
  • Output Escaping - All outputs escaped to prevent XSS
  • Prepared Statements - All database queries use $wpdb->prepare()
  • Mail Block Preservation - Existing pre_wp_mail blockers, including WP_Error, are preserved
  • CSV Export Hardening - Log exports neutralize spreadsheet formula prefixes

Reporting Security Issues

If you discover a security vulnerability, please report it via GitHub Security Advisories or create a private issue. Do not create a public issue for security vulnerabilities.

Compatibility

WordPress Plugins

Works seamlessly with any plugin using wp_mail():

  • ✅ WooCommerce
  • ✅ Contact Form 7
  • ✅ Gravity Forms
  • ✅ Easy Digital Downloads
  • ✅ MemberPress
  • ✅ BuddyPress
  • ✅ bbPress

Uninstallation

Upon deactivation:

  • Cron jobs are automatically cleared
  • Settings remain in database

Upon deletion:

  • Plugin settings are removed
  • Encryption keys are deleted
  • Scheduled events are cleared
  • Logs are preserved by default

To delete logs on uninstall, add to wp-config.php:

define('ENJINMEL_SMTP_PURGE_LOGS_ON_UNINSTALL', true);

Changelog

See CHANGELOG.md for detailed version history.

Current Version: 0.2.5

WordPress 7.0 compatibility and maintenance

  • Fixed: Restored legacy EngineMail compatibility helpers for settings, log migration, cron cleanup, and mail failure metadata.
  • Fixed: Hardened Send Test Email recipient validation to reject tampered input.
  • Fixed: Made log-table detection work with persistent WordPress tables and temporary PHPUnit tables.
  • Changed: Verified compatibility with WordPress 7.0 and aligned the test stack with PHPUnit 9.6 / wp-phpunit 7.0.
  • Changed: Removed the plugin bootstrap from Composer autoload.files so Composer dev tools run outside WordPress.

Previous Version: 0.2.4

Security fixes and hardening

  • Fixed: Preserve prior non-null pre_wp_mail return values, including WP_Error, before sending through EnjinMel.
  • Fixed: Neutralize spreadsheet formula prefixes in exported email log CSV values.
  • Hardened: Insert dynamic Send Test Email failure messages as text instead of HTML.
  • Tests: Added regression coverage for prior WP_Error preservation and CSV formula neutralization.

Previous Releases:

  • v0.2.3 - Plugin-check and packaging hygiene
  • v0.2.2 - Critical bug fixes and API V2 compliance
  • v0.2.0 - Major security and performance update
  • v0.1.0 - Initial release with Enginemailer REST API integration

Support

For support, documentation, issues, and feature requests, please refer to the project repository.

Contributing

Contributions are welcome!

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Run tests: composer test
  5. Check code standards: ./vendor/bin/phpcs
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Open a Pull Request

License

This project is licensed under the GNU General Public License v2.0 or later - see the LICENSE.txt file for details.

Credits

  • Author: Liew CheonFong
  • License: GPLv2 or later

Acknowledgments

  • Built for the WordPress community
  • Integrates with Enginemailer email service

Made for WordPress

About

Replace WordPress default email sending with the Enginemailer REST API for enhanced deliverability and reliability.

Resources

License

Stars

3 stars

Watchers

0 watching

Forks

Sponsor this project

Packages

 
 
 

Contributors