-
Notifications
You must be signed in to change notification settings - Fork 0
Mailhog
Mark Howells-Mead edited this page Aug 24, 2026
·
1 revision
<?php
/**
* Plugin Name: Local Email (MailHog)
* Description: Routes all outgoing mail to the local MailHog SMTP server.
* Author: LV2
*/
defined( 'ABSPATH' ) || exit;
add_action( 'phpmailer_init', function ( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = '127.0.0.1';
$phpmailer->Port = 1025;
$phpmailer->SMTPAuth = false;
$phpmailer->SMTPAutoTLS = false;
$phpmailer->SMTPSecure = '';
} );
// Sane sender so MailHog doesn't show wordpress@localhost everywhere.
add_filter( 'wp_mail_from', function () {
return 'wordpress@' . wp_parse_url( home_url(), PHP_URL_HOST );
} );
add_filter( 'wp_mail_from_name', function () {
return get_bloginfo( 'name' );
} );Mark Howells-Mead | https://permanenttourist.ch and https://sayhello.ch/ | Wiki since 2016
Use this code freely, widely and for free. Provision of this code provides and implies no guarantee.
Please respect the GPL v3 licence, which is available via http://www.gnu.org/licenses/gpl-3.0.html