Skip to content

Instantly share code, notes, and snippets.

@joedooley
Last active November 7, 2018 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joedooley/35a39bb412e1e2281b81d20d08a6aedd to your computer and use it in GitHub Desktop.
Save joedooley/35a39bb412e1e2281b81d20d08a6aedd to your computer and use it in GitHub Desktop.
Route all WordPress email through MailHog.
<?php
/**
* Plugin Name: MailHog Config
* Description: Route all WordPress email through MailHog.
* Version: 1.0.0
*
* @package LuminFire\MailHog
* @since 1.0.0
* @author LuminFire
* @link https://luminfire.com/
*/
namespace LuminFire\MailHog;
/**
* Routes all mail through Mailhog.
*
* @since 1.0.0
*
* @param $phpmailer
*
* @return void
*/
add_action( 'phpmailer_init', function ( $phpmailer ) {
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) {
return;
}
$phpmailer->isSMTP();
$phpmailer->Host = 'localhost';
$phpmailer->SMTPAuth = false;
$phpmailer->Port = '1025';
$phpmailer->From = 'admin@mn-grown.valet';
$phpmailer->FromName = 'MN Grown - Local Dev Environment';
// $phpmailer->Username = 'yourusername';
// $phpmailer->Password = 'yourpassword';
// $phpmailer->SMTPSecure = 'tls';
}, 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment