mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
merge
This commit is contained in:
commit
a8410b1b6a
8 changed files with 48 additions and 34 deletions
|
@ -39,6 +39,14 @@ namespace controllers\internals;
|
|||
{
|
||||
new \daemons\Webhook();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start mailer daemon.
|
||||
*/
|
||||
public function mailer()
|
||||
{
|
||||
new \daemons\Mailer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a phone daemon.
|
||||
|
|
|
@ -22,18 +22,18 @@ class Mailer extends \descartes\Controller
|
|||
$this->log->pushHandler(new StreamHandler(PWD_LOGS . '/mail.log', Logger::DEBUG));
|
||||
|
||||
$this->mail = new PHPMailer(true);
|
||||
$mail->SMTPDebug = SMTP::DEBUG_OFF;
|
||||
$mail->isSMTP();
|
||||
$mail->Host = MAIL['SMTP']['HOST'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = MAIL['SMTP']['USER'];
|
||||
$mail->Password = MAIL['SMTP']['PASS'];
|
||||
$mail->Port = MAIL['SMTP']['PORT'];
|
||||
$mail->setFrom(MAIL['FROM']);
|
||||
$this->mail->SMTPDebug = SMTP::DEBUG_OFF;
|
||||
$this->mail->isSMTP();
|
||||
$this->mail->Host = MAIL['SMTP']['HOST'];
|
||||
$this->mail->SMTPAuth = true;
|
||||
$this->mail->Username = MAIL['SMTP']['USER'];
|
||||
$this->mail->Password = MAIL['SMTP']['PASS'];
|
||||
$this->mail->Port = MAIL['SMTP']['PORT'];
|
||||
$this->mail->setFrom(MAIL['FROM']);
|
||||
|
||||
if (MAIL['SMTP']['TLS'])
|
||||
{
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$this->mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ class Mailer extends \descartes\Controller
|
|||
* @param array $datas : Datas to inject into email template
|
||||
* @return bool : true on success, false on error
|
||||
*/
|
||||
public function enqueue (string $destination, string $settings, string $datas) : bool
|
||||
public function enqueue (string $destination, array $settings, array $datas) : bool
|
||||
{
|
||||
$response = $this->generate_body($settings, $datas);
|
||||
|
||||
|
|
|
@ -189,24 +189,6 @@ namespace controllers\internals;
|
|||
return (bool) ($_SESSION['user']['admin'] ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cette fonction s'occupe d'envoyer les emails.
|
||||
*
|
||||
* @param string $to : L'adresse mail à laquelle envoyer le mail
|
||||
* @param array $settings : Les settings du mail, type, sujet, template
|
||||
* @param array $datas : Les données à fournir au template du mail
|
||||
*/
|
||||
public static function send_email($to, $settings, $datas = [])
|
||||
{
|
||||
$controller = new \descartes\Controller();
|
||||
|
||||
ob_start();
|
||||
$controller->render($settings['template'], $datas);
|
||||
$content = ob_get_clean();
|
||||
|
||||
return @mail($to, $settings['subject'], $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow to read an uploaded file.
|
||||
*
|
||||
|
|
|
@ -119,8 +119,9 @@ namespace controllers\publics;
|
|||
$token = $Tokenista->generate(3600, ['id_user' => $user['id']]);
|
||||
|
||||
$reset_link = \descartes\Router::url('Connect', 'reset_password', ['id_user' => $user['id'], 'token' => $token]);
|
||||
|
||||
\controllers\internals\Tool::send_email($email, EMAIL_RESET_PASSWORD, ['reset_link' => $reset_link]);
|
||||
|
||||
$mailer = new \controllers\internals\Mailer();
|
||||
$email_send = $mailer->enqueue($email, EMAIL_RESET_PASSWORD, ['reset_link' => $reset_link]);
|
||||
|
||||
return $this->render('connect/send-reset-password');
|
||||
}
|
||||
|
|
|
@ -171,7 +171,8 @@ class User extends \descartes\Controller
|
|||
return $this->redirect(\descartes\Router::url('User', 'add'));
|
||||
}
|
||||
|
||||
$email_send = \controllers\internals\Tool::send_email($email, EMAIL_CREATE_USER, ['email' => $email, 'password' => $password]);
|
||||
$mailer = new \controllers\internals\Mailer();
|
||||
$email_send = $mailer->enqueue($email, EMAIL_CREATE_USER, ['email' => $email, 'password' => $password]);
|
||||
if (!$email_send)
|
||||
{
|
||||
\FlashMessage\FlashMessage::push('danger', 'Impossible d\'envoyer l\'e-mail à l\'utilisateur.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue