From 1244b4bd48fe1276bf7dbc2e92e514cc82aca884 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 19 Feb 2021 14:56:06 -0500 Subject: [PATCH] Update wireMail fallback from email settings with 2nd check in case 3rd party module made default blank, plus update auto-detect from email logic in ProcessForgotPassword so it can't override configured wireMail settings with config.adminEmail --- wire/core/WireMail.php | 5 ++++- .../ProcessForgotPassword/ProcessForgotPassword.module | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wire/core/WireMail.php b/wire/core/WireMail.php index 320d1a1a..5c672122 100644 --- a/wire/core/WireMail.php +++ b/wire/core/WireMail.php @@ -629,10 +629,13 @@ class WireMail extends WireData implements WireMailInterface { */ protected function renderMailHeader() { + $settings = $this->wire()->config->wireMail; $from = $this->from; + + if(!strlen($from) && !empty($settings['from'])) $from = $settings['from']; if(!strlen($from)) $from = $this->wire('config')->adminEmail; if(!strlen($from)) $from = 'processwire@' . $this->wire('config')->httpHost; - + $header = "From: " . ($this->fromName ? $this->bundleEmailAndName($from, $this->fromName) : $from); foreach($this->header as $key => $value) { diff --git a/wire/modules/Process/ProcessForgotPassword/ProcessForgotPassword.module b/wire/modules/Process/ProcessForgotPassword/ProcessForgotPassword.module index 207b3d18..dd1a28c1 100644 --- a/wire/modules/Process/ProcessForgotPassword/ProcessForgotPassword.module +++ b/wire/modules/Process/ProcessForgotPassword/ProcessForgotPassword.module @@ -939,6 +939,10 @@ class ProcessForgotPassword extends Process implements ConfigurableModule { */ protected function getEmailFrom() { $emailFrom = $this->emailFrom; + if(empty($emailFrom)) { + $settings = $this->wire()->config->wireMail; + if(!empty($settings['from'])) $emailFrom = $settings['from']; + } if(empty($emailFrom)) $emailFrom = $this->wire('config')->adminEmail; if(empty($emailFrom)) $emailFrom = 'noreply@' . $this->wire('config')->httpHost; return $emailFrom;