65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace com\fwdekker\deathnotifier\mailer;
|
|
|
|
use com\fwdekker\deathnotifier\UserManager;
|
|
|
|
|
|
/**
|
|
* An email to be sent to a recently registered user, including instructions for email verification.
|
|
*/
|
|
class RegisterEmail extends Email
|
|
{
|
|
/**
|
|
* A string identifying the type of email.
|
|
*/
|
|
public const TYPE = "register";
|
|
|
|
/**
|
|
* @var string The token to verify the email address with.
|
|
*/
|
|
public string $token;
|
|
|
|
|
|
/**
|
|
* Constructs an email to be sent to a recently registered user, including instructions for email 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 "Welcome to Death Notifier";
|
|
}
|
|
|
|
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 have successfully created an account with Death Notifier. " .
|
|
"Welcome!" .
|
|
"\n\n" .
|
|
"Until you verify your email address, you will not receive any notifications. " .
|
|
"You can verify your email address by clicking the link below. " .
|
|
"This link will expire after " . UserManager::MINUTES_VALID_VERIFICATION . " minutes." .
|
|
"\n" .
|
|
"Verify: $verify_path" .
|
|
"\n\n" .
|
|
"If you did not create this account, you can delete the account. " .
|
|
"Go to the Death Notifier website, reset your password, log in, and delete the account." .
|
|
"\n\n" .
|
|
$base_path;
|
|
}
|
|
}
|