|
|
@@ -58,14 +58,21 @@ class User extends Model {
|
|
|
$this->verify_token = bin2hex(random_bytes(16));
|
|
|
$this->commit();
|
|
|
|
|
|
- $mail = new Email();
|
|
|
-
|
|
|
- $mail->loadHtmlTemplate("registration");
|
|
|
- $mail->setValues([
|
|
|
- "name" => $this->first_name,
|
|
|
- "link" => PROTOCOL . "://" . DOMAIN . "/verify-email/" . $this->verify_token
|
|
|
- ]);
|
|
|
-
|
|
|
+ // Content
|
|
|
+ $name = htmlspecialchars($this->first_name);
|
|
|
+ $link = htmlspecialchars(PROTOCOL . "://" . DOMAIN . "/verify-email/" . $this->verify_token);
|
|
|
+
|
|
|
+ // Build
|
|
|
+ $builder = new EmailBuilder;
|
|
|
+ $builder->addParagraph("<b>Hi $name</b>");
|
|
|
+ $builder->addLeadParagraph("Thanks for registering!");
|
|
|
+ $builder->addParagraph("Welcome to Check Policy! Before you can log in, you will need to verify your email address. You can do so by tapping the following link:");
|
|
|
+ $builder->addParagraph("<a href=\"$link\">$link</a>");
|
|
|
+ $content = $builder->build();
|
|
|
+
|
|
|
+ // Send
|
|
|
+ $mail = new Email;
|
|
|
+ $mail->setHtmlContent($content);
|
|
|
$mail->setFrom(EMAIL_NO_REPLY, EMAIL_FROM_NAME);
|
|
|
$mail->addAddress($this->email, $this->getDisplayName());
|
|
|
|
|
|
@@ -78,19 +85,24 @@ class User extends Model {
|
|
|
|
|
|
public function sendWelcomeEmail() {
|
|
|
|
|
|
- $mail = new Email();
|
|
|
-
|
|
|
- $mail->loadHtmlTemplate("welcome");
|
|
|
- $mail->setValues([
|
|
|
- "name" => $this->first_name,
|
|
|
- "link" => PROTOCOL . "://" . DOMAIN . "/account/submit-id"
|
|
|
- ]);
|
|
|
-
|
|
|
+ // Content
|
|
|
+ $name = htmlspecialchars($this->first_name);
|
|
|
+ $link = htmlspecialchars(PROTOCOL . "://" . DOMAIN . "/account/submit-id");
|
|
|
+
|
|
|
+ // Build
|
|
|
+ $builder = new EmailBuilder;
|
|
|
+ $builder->addParagraph("<b>Hi $name</b>");
|
|
|
+ $builder->addLeadParagraph("Thanks for verifying your email address!");
|
|
|
+ $builder->addParagraph("Welcome to Check Policy! Before you can take part in tests, you will need to provide us with some ID. You can do so by tapping the following link:");
|
|
|
+ $builder->addParagraph("<a href=\"$link\">$link</a>");
|
|
|
+ $content = $builder->build();
|
|
|
+
|
|
|
+ // Send
|
|
|
+ $mail = new Email;
|
|
|
+ $mail->setHtmlContent($content);
|
|
|
$mail->setFrom(EMAIL_NO_REPLY, EMAIL_FROM_NAME);
|
|
|
$mail->addAddress($this->email, $this->getDisplayName());
|
|
|
-
|
|
|
$mail->setSubject("Welcome to Check Policy");
|
|
|
-
|
|
|
$mail->send();
|
|
|
|
|
|
return true;
|
|
|
@@ -102,14 +114,23 @@ class User extends Model {
|
|
|
$this->reset_token = bin2hex(random_bytes(16));
|
|
|
$this->commit();
|
|
|
|
|
|
- $mail = new Email();
|
|
|
+ // Content
|
|
|
+ $name = htmlspecialchars($this->first_name);
|
|
|
+ $link = htmlspecialchars(PROTOCOL . "://" . DOMAIN . "/reset-password/" . $this->reset_token);
|
|
|
|
|
|
- $mail->loadHtmlTemplate("password_reset");
|
|
|
- $mail->setValues([
|
|
|
- "name" => $this->first_name,
|
|
|
- "link" => PROTOCOL . "://" . DOMAIN . "/reset-password/" . $this->reset_token
|
|
|
- ]);
|
|
|
+ // Build
|
|
|
+ $builder = new EmailBuilder;
|
|
|
+ $builder->addParagraph("<b>Hi $name</b>");
|
|
|
+ $builder->addLeadParagraph("A reset password request has been received.");
|
|
|
+ $builder->addParagraph("To reset your password, please tap on the following link:");
|
|
|
+ $builder->addParagraph("<a href=\"$link\">$link</a>");
|
|
|
+ $builder->addParagraph("If you <strong>did not</strong> request for your password to be reset, please ignore this email.");
|
|
|
+ $content = $builder->build();
|
|
|
+
|
|
|
+ // Send
|
|
|
|
|
|
+ $mail = new Email;
|
|
|
+ $mail->setHtmlContent($content);
|
|
|
$mail->setFrom(EMAIL_NO_REPLY, EMAIL_FROM_NAME);
|
|
|
$mail->addAddress($this->email, $this->getDisplayName());
|
|
|
|