Add email verification code sending (close #3)

master
Skylar Ittner 6 years ago
parent 2e01a25d95
commit fd44dd9a93

@ -20,8 +20,17 @@ if (!empty($_POST['email'])) {
$_SESSION['code'] = $code;
$_SESSION['maybefamily'] = $database->get('families', 'familyid', ['email' => strtolower($_POST['email'])]);
// TODO: send email
file_put_contents("/var/www/html/code.txt", $code);
try {
$verification = new Email();
$verification->addTo(NOTIFICATION_TO);
$verification->setFrom(SMTP_FROMADDRESS, SMTP_FROMNAME);
$verification->setSMTP(SMTP_HOST, SMTP_PORT, SMTP_AUTH, SMTP_USERNAME, SMTP_PASSWORD, SMTP_SECURITY);
$verification->setSubject("HACHE email verification");
$verification->setBody("The verification code for renewing your HACHE membership is $code.");
$verification->send();
} catch (Exception $e) {
}
} else if (!empty($_POST['code'])) {
if (empty($_SESSION['code'])) {
header("Location: ./?page=renew&msg=sessionexpired");

Loading…
Cancel
Save