Commit 9dc17ca5 authored by Tino Goratsch's avatar Tino Goratsch

send a HTML email when an user registers a new account

parent b405fd73
...@@ -116,28 +116,7 @@ class Register extends Core\Controller\AbstractFrontendAction ...@@ -116,28 +116,7 @@ class Register extends Core\Controller\AbstractFrontendAction
$this->registrationFormValidation->validate($formData); $this->registrationFormValidation->validate($formData);
$systemSettings = $this->config->getSettings(Schema::MODULE_NAME); $mailIsSent = $this->sendRegistrationEmail($formData);
$settings = $this->config->getSettings(Users\Installer\Schema::MODULE_NAME);
$subject = $this->translator->t(
'users',
'register_mail_subject',
[
'{title}' => $systemSettings['site_title'],
'{host}' => $this->request->getHost(),
]);
$body = $this->translator->t(
'users',
'register_mail_message',
[
'{name}' => $formData['nickname'],
'{mail}' => $formData['mail'],
'{password}' => $formData['pwd'],
'{title}' => $systemSettings['site_title'],
'{host}' => $this->request->getHost()
]
);
$mailIsSent = $this->sendEmail->execute('', $formData['mail'], $settings['mail'], $subject, $body);
$salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH); $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
$insertValues = [ $insertValues = [
...@@ -154,11 +133,50 @@ class Register extends Core\Controller\AbstractFrontendAction ...@@ -154,11 +133,50 @@ class Register extends Core\Controller\AbstractFrontendAction
$this->setTemplate($this->get('core.helpers.alerts')->confirmBox( $this->setTemplate($this->get('core.helpers.alerts')->confirmBox(
$this->translator->t('users', $this->translator->t('users',
$mailIsSent === true && $lastId !== false && $bool2 !== false ? 'register_success' : 'register_error'), $mailIsSent === true && $lastId !== false && $bool2 !== false ? 'register_success' : 'register_error'
),
$this->appPath->getWebRoot() $this->appPath->getWebRoot()
)); ));
}, },
$this->request->getFullPath() $this->request->getFullPath()
); );
} }
/**
* @param array $formData
* @return bool
*/
protected function sendRegistrationEmail(array $formData)
{
$systemSettings = $this->config->getSettings(Schema::MODULE_NAME);
$settings = $this->config->getSettings(Users\Installer\Schema::MODULE_NAME);
$subject = $this->translator->t(
'users',
'register_mail_subject',
[
'{title}' => $systemSettings['site_title'],
'{host}' => $this->request->getHost(),
]);
$body = $this->translator->t(
'users',
'register_mail_message',
[
'{name}' => $formData['nickname'],
'{mail}' => $formData['mail'],
'{password}' => $formData['pwd'],
'{title}' => $systemSettings['site_title'],
'{host}' => $this->request->getHost()
]
);
$data = (new Core\Mailer\MailerMessage())
->setRecipients($formData['mail'])
->setFrom($settings['mail'])
->setSubject($subject)
->setBody($body)
->setTemplate('Users/layout.email.register.tpl');
return $this->sendEmail->execute($data);
}
} }
{extends file="asset:System/layout.email.tpl"} {extends file="asset:Users/layout.email.register.tpl"}
{block EMAIL_HEAD}
<title>{$mail.title}</title>
{/block}
{block EMAIL_CONTENT}
{$mail.body}
{/block}
{extends file="asset:System/layout.email.tpl"}
{block EMAIL_HEAD}
<title>{$mail.title}</title>
{/block}
{block EMAIL_CONTENT}
{$mail.body}
{/block}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment