Skip to content

Instantly share code, notes, and snippets.

@pxdsgnco
Forked from bishless/wp-mailhog.php
Created June 7, 2018 15:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pxdsgnco/d6f2c36716f7cd9f9806447da48d5674 to your computer and use it in GitHub Desktop.
Save pxdsgnco/d6f2c36716f7cd9f9806447da48d5674 to your computer and use it in GitHub Desktop.
Configure WordPress on Valet to use MailHog
<?php
/**
* @link
* @since 1.0.0
* @package TODO
*
* @wordpress-plugin
* Plugin Name: Use MailHog
* Description: Configure WordPress on Valet to use MailHog
* Version: 1.0.0
* Tags: local, email
*/
add_action( 'phpmailer_init', 'bish_configMH', 10, 1 );
function bish_configMH( $phpmailer ) {
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mailserver
$phpmailer->Host = 'localhost';
// Use SMTP authentication (true|false)
$phpmailer->SMTPAuth = false;
// SMTP port number
// Mailhog normally run on port 1025
$phpmailer->Port = WP_DEBUG ? '1025' : '25';
// Username to use for SMTP authentication
// $phpmailer->Username = 'yourusername';
// Password to use for SMTP authentication
// $phpmailer->Password = 'yourpassword';
// The encryption system to use - ssl (deprecated) or tls
// $phpmailer->SMTPSecure = 'tls';
$phpmailer->From = 'site_adm@wp.local';
$phpmailer->FromName = 'WP DEV';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment