Email testing is important for WordPress testing because WordPress coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. relies on transactional emails for essential functions like user registration, password resets, and admin notifications. Capturing and verifying these emails ensures that the correct messages are triggered with proper content and formatting during the testing process.
Email Capture Methods for Different Testing Environments
Depending on your testing environment, you can use:
- Email Logger pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party. that hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. into the wp_mail function.
- Mailpit, a lightweight email testing tool that provides a web interface to view the captured emails.
1. Using Email Logger Plugin
This method can be used on your local development environment as well as on WordPress Playground, and doesn’t have external dependencies or require a technical configuration.
Steps to use:
- Download the plugin, install it from
Plugins > Add Plugin > Upload Pluginand activate it. - Use the
Email Logmenu item to view captured emails.
You can also use this WordPress Playground instance that comes with Email Logger plugin preinstalled.
2. Using Mailpit
Mailpit is a lightweight email testing tool that runs locally and captures all outgoing emails from your development environment, providing a web interface where you can view, inspect, and test emails without actually sending them to real recipients.
You can browse emails easily through Mailpit’s user interface that acts as a mail client.
Steps to install and use Mailpit:
- Create
docker-compose.override.ymlwith the following code in root folder of your cloned WordPress Develop Repo.
services:
mail:
container_name: mailpit
image: axllent/mailpit
restart: unless-stopped
ports:
- '1025:1025' # smtp server
- '8025:8025' # web ui
environment:
MP_MAX_MESSAGES: 5000
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
networks:
- wpdevnet
- Run the command
docker compose up -d mailin your terminal. - Test access to Mailpit at `http://localhost:8025/`.
- Add the following snippet to your active theme’s
functions.phpor via Code Snippets plugin.
add_action( 'phpmailer_init', function( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = 'localhost';
$phpmailer->Port = 1025;
} );
add_filter( 'wp_mail_from', function( $email ) {
return 'noreply@example.com';
});
Other Tools for Mail Testing
- For testing emails with WordPress Studio you can use WP Mail by @jonathanbossenger, a desktop application for logging and viewing emails sent from WordPress Studio local sites.
Conclusion
Without a mail testing mechanism like the ones described here, transactional emails triggered during testing would either fail silently or be sent to real email addresses, making it difficult to verify that WordPress core functionality is working correctly.
By using the tool suitable for your testing environment, you can capture and inspect outgoing emails to ensure they’re triggered properly with the correct content and formatting.



