Mailhog - markhowellsmead/helpers GitHub Wiki
Must use plugin
<?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' );
} );