From 5fa8cddd0c22a5d4eeda90c45467731aac0641e3 Mon Sep 17 00:00:00 2001 From: Roly Rudy Gutierrez Pinto Date: Tue, 3 Dec 2019 14:37:16 -0400 Subject: [PATCH] PMC-1457 Test Email is not send when the users doesn't fill the "Sender Email" field --- .../src/ProcessMaker/GmailOAuth/GmailOAuth.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuth.php b/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuth.php index 277644cb6..36d0000a0 100644 --- a/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuth.php +++ b/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuth.php @@ -317,9 +317,6 @@ class GmailOAuth if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) { return $googleServiceGmailMessage; } - if (!filter_var($this->senderEmail, FILTER_VALIDATE_EMAIL)) { - return $googleServiceGmailMessage; - } if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) { return $googleServiceGmailMessage; } @@ -391,15 +388,20 @@ class GmailOAuth if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) { return $phpMailerOAuth; } - if (!filter_var($this->senderEmail, FILTER_VALIDATE_EMAIL)) { - return $phpMailerOAuth; - } if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) { return $phpMailerOAuth; } if ($this->sendTestMail === 0) { return $phpMailerOAuth; } + $senderEmail = $this->senderEmail; + if (!filter_var($senderEmail, FILTER_VALIDATE_EMAIL)) { + $senderEmail = $this->fromAccount; + } + if (empty($this->senderName)) { + $this->senderName = ""; + } + $phpMailerOAuth->isHTML(true); $phpMailerOAuth->isSMTP(); $phpMailerOAuth->Host = 'smtp.gmail.com'; @@ -409,7 +411,7 @@ class GmailOAuth $phpMailerOAuth->oauthClientId = $this->clientID; $phpMailerOAuth->oauthClientSecret = $this->clientSecret; $phpMailerOAuth->oauthRefreshToken = $this->refreshToken; - $phpMailerOAuth->SetFrom($this->senderEmail, $this->senderName); + $phpMailerOAuth->SetFrom($senderEmail, $this->senderName); $phpMailerOAuth->Subject = G::LoadTranslation("ID_MESS_TEST_SUBJECT"); $phpMailerOAuth->Body = utf8_encode($this->getMessageBody()); $phpMailerOAuth->AddAddress($this->mailTo);