File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ configuration.
205205` BM_WP_SMTP_PASSWORD ` - Define the SMTP e-mail account password to send through.
206206` BM_WP_SMTP_PORT ` - Set which port the connection should be made through. Should be set as an integer. Defaults to ` 587 ` .
207207` BM_WP_SMTP_SECURITY ` - Set the sending security for the SMTP server. Defaults to ` tls ` .
208+ ` BM_WP_SMTP_SITE_IDS ` - Set side ids in an array to only use SMTP for some sites in a multisite. Defaults to work for all sites.
208209
209210` BM_WP_POSTAL_DOMAIN ` - Optionally customize the domain for the Postal install. Defaults to ` https://postal.oderland.com `
210211` BM_WP_POSTAL_API_KEY ` - Add the API key for the Postal service. Without it, Postal is not active.
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ public static function warn_improper_smtp_configuration(): void {
2222 return ;
2323 }
2424
25+ if ( ! self ::should_send_for_this_site () ){
26+ return ;
27+ }
28+
2529 if ( self ::are_all_configs_set () ) {
2630 return ;
2731 }
@@ -39,6 +43,7 @@ public static function warn_improper_smtp_configuration(): void {
3943
4044 public static function send_mail_via_smtp ( PHPMailer $ mailer ): void {
4145
46+ if ( ! )
4247 if ( ! self ::should_send_via_smtp () ) {
4348 return ;
4449 }
@@ -56,6 +61,22 @@ public static function send_mail_via_smtp( PHPMailer $mailer ): void {
5661 $ mailer ->isSMTP ();
5762 }
5863
64+ protected static function should_send_for_this_site (): bool {
65+ if ( ! is_multisite () ){
66+ return true ;
67+ }
68+
69+ if ( ! defined ( 'BM_WP_SMTP_SITE_IDS ' ) ){
70+ return true ;
71+ }
72+
73+ if ( is_array ( BM_WP_SMTP_SITE_IDS ) && in_array ( get_current_blog_id (), BM_WP_SMTP_SITE_IDS ) ){
74+ return true ;
75+ }
76+
77+ return false ;
78+ }
79+
5980 protected static function should_send_via_smtp (): bool {
6081 if ( 'production ' !== wp_get_environment_type () ) {
6182 return self ::should_send_smtp_outside_production ();
You can’t perform that action at this time.
0 commit comments