Skip to content

Instantly share code, notes, and snippets.

@csalzano
Forked from bishless/wp-mailhog.php
Last active December 5, 2023 15:16
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 csalzano/fd69d35a99cd5ba68ab72db36cfb63b0 to your computer and use it in GitHub Desktop.
Save csalzano/fd69d35a99cd5ba68ab72db36cfb63b0 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
*/
if ( ! function_exists( 'phpmailer_use_mailhog' ) ) {
add_action( 'phpmailer_init', 'phpmailer_use_mailhog', 10, 1 );
function phpmailer_use_mailhog( $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 = defined( 'WP_DEBUG' ) && 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';
// Change the from address
// $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