Merged in bugfix/PMC-1457 (pull request #7169)

PMC-1457 Test Email is not send when the users doesn't fill the "Sender Email" field

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Roly
2019-12-03 19:25:30 +00:00
committed by Julio Cesar Laura Avendaño

View File

@@ -317,9 +317,6 @@ class GmailOAuth
if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) { if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) {
return $googleServiceGmailMessage; return $googleServiceGmailMessage;
} }
if (!filter_var($this->senderEmail, FILTER_VALIDATE_EMAIL)) {
return $googleServiceGmailMessage;
}
if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) { if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) {
return $googleServiceGmailMessage; return $googleServiceGmailMessage;
} }
@@ -391,15 +388,20 @@ class GmailOAuth
if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) { if (!filter_var($this->fromAccount, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth; return $phpMailerOAuth;
} }
if (!filter_var($this->senderEmail, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth;
}
if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) { if (!filter_var($this->mailTo, FILTER_VALIDATE_EMAIL)) {
return $phpMailerOAuth; return $phpMailerOAuth;
} }
if ($this->sendTestMail === 0) { if ($this->sendTestMail === 0) {
return $phpMailerOAuth; 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->isHTML(true);
$phpMailerOAuth->isSMTP(); $phpMailerOAuth->isSMTP();
$phpMailerOAuth->Host = 'smtp.gmail.com'; $phpMailerOAuth->Host = 'smtp.gmail.com';
@@ -409,7 +411,7 @@ class GmailOAuth
$phpMailerOAuth->oauthClientId = $this->clientID; $phpMailerOAuth->oauthClientId = $this->clientID;
$phpMailerOAuth->oauthClientSecret = $this->clientSecret; $phpMailerOAuth->oauthClientSecret = $this->clientSecret;
$phpMailerOAuth->oauthRefreshToken = $this->refreshToken; $phpMailerOAuth->oauthRefreshToken = $this->refreshToken;
$phpMailerOAuth->SetFrom($this->senderEmail, $this->senderName); $phpMailerOAuth->SetFrom($senderEmail, $this->senderName);
$phpMailerOAuth->Subject = G::LoadTranslation("ID_MESS_TEST_SUBJECT"); $phpMailerOAuth->Subject = G::LoadTranslation("ID_MESS_TEST_SUBJECT");
$phpMailerOAuth->Body = utf8_encode($this->getMessageBody()); $phpMailerOAuth->Body = utf8_encode($this->getMessageBody());
$phpMailerOAuth->AddAddress($this->mailTo); $phpMailerOAuth->AddAddress($this->mailTo);