Skip to content

Instantly share code, notes, and snippets.

@mrcave
Last active September 24, 2020 03:23
Show Gist options
  • Save mrcave/5c56c803eaeafe01261eeded4b9c2067 to your computer and use it in GitHub Desktop.
Save mrcave/5c56c803eaeafe01261eeded4b9c2067 to your computer and use it in GitHub Desktop.
WordPress multisite PHP mailer override for use with transactional email service
<?php
//this file goes in /wp-content/mu-plugins
//https://gist.github.com/butlerblog/c5c5eae5ace5bdaefb5d
//constant configs in wp-config.php
add_action( 'phpmailer_init', 'use_smtp_email' );
function use_smtp_email( $phpmailer ) {
$phpmailer->isSMTP();
//https://deluxeblogtips.com/send-html-emails-in-wordpress/
$phpmailer->IsHTML( true );
$phpmailer->Host = SMTP_HOST;
$phpmailer->SMTPAuth = SMTP_AUTH;
$phpmailer->Port = SMTP_PORT;
$phpmailer->Username = SMTP_USER;
$phpmailer->Password = SMTP_PASS;
$phpmailer->SMTPSecure = SMTP_SECURE;
$phpmailer->From = SMTP_FROM;
$phpmailer->FromName = SMTP_NAME;
}
<?php
//this gets added to wp-config.php
define( "SMTP_USER", "user-id-here" );
define( "SMTP_PASS", "user-pass-here" );
define( "SMTP_HOST", "smtp.postmarkapp.com" );
define( "SMTP_FROM", "[email protected]" );
define( "SMTP_NAME", "Network Name" );
define( "SMTP_PORT", "587" );
define( "SMTP_SECURE", "tls" );
define( "SMTP_AUTH", true );
define( "SMTP_DEBUG", 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment