death-notifier/src/main/php/com/fwdekker/deathnotifier/mailer/ChangedEmailEmail.php

61 lines
1.7 KiB
PHP

<?php
namespace com\fwdekker\deathnotifier\mailer;
use com\fwdekker\deathnotifier\UserManager;
/**
* An email informing a user that their email has been changed, and needs verification.
*/
class ChangedEmailEmail extends Email
{
/**
* A string identifying the type of email.
*/
public const TYPE = "changed-email";
/**
* @var string The token to verify the email address with.
*/
public string $token;
/**
* Constructs an email informing a user that their email has been changed, and needs verification.
*
* @param string $recipient the intended recipient of the email
* @param string $token the token to verify the email address with
*/
public function __construct(string $recipient, string $token)
{
$this->type = self::TYPE;
$this->recipient = $recipient;
$this->token = $token;
$this->arg1 = $token;
}
public function getSubject(): string
{
return "Verify your new email address";
}
public function getBody(array $config): string
{
$base_path = $config["server"]["base_path"];
$verify_path = "$base_path?action=verify-email&email=" . rawurlencode($this->recipient) . "&token=$this->token";
return
"You changed the email address of your Death Notifier account. " .
"Until you verify your email address, you will not receive any notifications. " .
"You can verify your new email address by clicking the link below. " .
"This link will expire after " . UserManager::MINUTES_VALID_VERIFICATION . " minutes." .
"\n" .
"Verify: $verify_path" .
"\n\n" .
$base_path;
}
}