Skip to content

Instantly share code, notes, and snippets.

@Log1x
Created March 11, 2022 16:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Log1x/2b53a11602711d8161b2edf0f5efd880 to your computer and use it in GitHub Desktop.
Save Log1x/2b53a11602711d8161b2edf0f5efd880 to your computer and use it in GitHub Desktop.
Simple PHPMailer SMTP mu-plugin
<?php
use function Env\env;
/**
* Plugin Name: PHPMailer SMTP
* Plugin URI: https://roots.io/bedrock/
* Description: Simple PHPMailer SMTP configuration for Bedrock.
* Version: 1.0.0
* Author: Roots
* Author URI: https://roots.io/
* License: MIT License
*/
add_filter('phpmailer_init', function ($mail) {
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = env('WP_ENV') === 'development' ? 'localhost' : env('WP_SMTP_HOST');
$mail->Port = env('WP_ENV') === 'development' ? 1025 : 587;
$mail->Username = env('WP_SMTP_USERNAME');
$mail->Password = env('WP_SMTP_PASSWORD');
$mail->Timeout = 10;
$mail->setFrom(
env('WP_SMTP_FORCEFROM'),
env('WP_SMTP_FORCEFROMNAME')
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment