{
$found = userbymail($email);
if (!$found) return FALSE;
+ $user = new User("profile/$found");
+ if (empty($user)) return FALSE;
$token = substr(sha1('$Random'.rand()), 0, 10);
if (!file_put_contents("profile/$found/.token", $token))
throw new Exception("could not store token for $found");
- $sitename = $_SERVER['HTTP_HOST'];
+ $sitename = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
$sitelink = 'https://'.$sitename;
$rep = [
- '[[user]]' => $found,
+ '[[user]]' => $user->name ?: $found,
'[[link]]' => "$sitelink/login/pass?token=$found:$token",
'[[site]]' => $sitename,
];
$mailbody = str_replace(array_keys($rep), array_values($rep), $mailbody);
if (!$mailbody) throw new Exception('empty mail body');
$mailsub = "Wachtwoord-reset voor $sitename";
+ $mailhead = "From: $sitename <info@$sitename>";
+ $rcpt = "$found <$email>";
- return mail($email, $mailsub, $mailbody);
+ return mail($rcpt, $mailsub, $mailbody, $mailhead);
return TRUE;
}