aboutsummaryrefslogtreecommitdiff
path: root/app/Mailers/UserMailer.php
blob: 4d657bf69dc80312368eb6a91ef88e65307c3846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);

/**
 * Manage the emails sent to the users.
 */
class FreshRSS_User_Mailer extends Minz_Mailer {

	/**
	 * @var FreshRSS_View
	 */
	protected $view;

	public function __construct() {
		parent::__construct(FreshRSS_View::class);
	}

	public function send_email_need_validation(string $username, FreshRSS_UserConfiguration $user_config): bool {
		Minz_Translate::reset($user_config->language);

		$this->view->_path('user_mailer/email_need_validation.txt.php');

		$this->view->username = $username;
		$this->view->site_title = FreshRSS_Context::systemConf()->title;
		$this->view->validation_url = Minz_Url::display(
			[
				'c' => 'user',
				'a' => 'validateEmail',
				'params' => [
					'username' => $username,
					'token' => $user_config->email_validation_token,
				],
			],
			'txt',
			true
		);

		$subject_prefix = '[' . FreshRSS_Context::systemConf()->title . ']';
		return $this->mail(
			$user_config->mail_login,
			$subject_prefix . ' ' . _t('user.mailer.email_need_validation.title')
		);
	}
}