Skip to content

Commit

Permalink
Fixed a bug where placeholders in the subject were not processed
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Jan 15, 2022
1 parent 3844202 commit 75b7bcc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions system/classes/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ public static function stripControlCharacters($item)
* Replace placeholders in the mail body with their actual values
*
* @param string $address
* @param string $subject
* @param string $body
* @return string
* @return void
*/
private static function replacePlaceHolders($address, $body)
private static function replacePlaceHolders($address, &$subject, &$body)
{
global $_CONF, $_TABLES;

Expand All @@ -51,7 +52,7 @@ private static function replacePlaceHolders($address, $body)
SELECT u.*, i.location, i.lastgranted, i.lastlogin FROM {$_TABLES['users']} AS u
LEFT JOIN {$_TABLES['userinfo']} AS i
ON u.uid = i.uid
WHERE u.email = '{$address}'
WHERE u.email = '$address'
SQL;
$resultSet = DB_query($sql);

Expand Down Expand Up @@ -80,11 +81,10 @@ private static function replacePlaceHolders($address, $body)
$_CONF['site_mail'], $_CONF['noreply_mail'],
];

$subject = str_replace($search, $replace, $subject);
$body = str_replace($search, $replace, $body);
}
}

return $body;
}

/**
Expand Down Expand Up @@ -220,7 +220,9 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr
} else {
$address = $to;
}
$body = self::replacePlaceHolders($address, $body);

// Replace placeholders
self::replacePlaceHolders($address, $subject, $body);

$mail->Body = $body;

Expand All @@ -246,7 +248,7 @@ public static function send($to, $subject, $body, $from = '', $html = false, $pr
$mail->addCustomHeader('X-Mailer', 'Geeklog ' . VERSION);

if (!empty(IP::getIPAddress()) && !empty($_SERVER['SERVER_ADDR'])
&& (IP::getIPAddress() !== $_SERVER['SERVER_ADDR'])) {
&& (IP::getIPAddress() !== $_SERVER['SERVER_ADDR'])) {
$url = COM_getCurrentURL();

if (substr($url, 0, strlen($_CONF['site_admin_url'])) !== $_CONF['site_admin_url']) {
Expand Down

0 comments on commit 75b7bcc

Please sign in to comment.