Created
March 11, 2022 16:03
-
-
Save Log1x/2b53a11602711d8161b2edf0f5efd880 to your computer and use it in GitHub Desktop.
Simple PHPMailer SMTP mu-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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