Skip to content

Instantly share code, notes, and snippets.

@bishless
Created June 2, 2017 23:03
Show Gist options
  • Save bishless/44ec6f6d3da0cc4a02bbc04ce5465c3b to your computer and use it in GitHub Desktop.
Save bishless/44ec6f6d3da0cc4a02bbc04ce5465c3b 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 = '[email protected]';
$phpmailer->FromName = 'WP DEV';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment