Send test email feature added to email settings.
This commit is contained in:
@@ -6,6 +6,7 @@ use api\classes\API;
|
|||||||
|
|
||||||
require_once 'API.php';
|
require_once 'API.php';
|
||||||
|
|
||||||
|
|
||||||
class API_mailsettings extends API
|
class API_mailsettings extends API
|
||||||
{
|
{
|
||||||
public function updateMailSettings($updatePassword)
|
public function updateMailSettings($updatePassword)
|
||||||
@@ -27,4 +28,19 @@ class API_mailsettings extends API
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSendMail($mailBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
$mailBuilder->subject = "Test mail";
|
||||||
|
$mailBuilder->addAddress($this->data['mail_to'], $this->data['mail_to']);
|
||||||
|
$mailBuilder->mailText = '
|
||||||
|
Hello,<br><br>
|
||||||
|
|
||||||
|
This is a test email sent through Sentri.<br><br>
|
||||||
|
|
||||||
|
If you received this email, your Sentri mail settings are configured correctly.
|
||||||
|
';
|
||||||
|
$mailBuilder->sendMail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
30
pub/api/v1/portal-management/mail/test/index.php
Normal file
30
pub/api/v1/portal-management/mail/test/index.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use api\classes\API_mailsettings;
|
||||||
|
use bin\php\Classes\mailBuilder;
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_mailsettings.php';
|
||||||
|
require_once $_SERVER['DOCUMENT_ROOT'] . '/bin/php/Classes/mailBuilder.php';
|
||||||
|
|
||||||
|
$API_mailsettings = new API_mailsettings();
|
||||||
|
|
||||||
|
if ($API_mailsettings->request_method === 'POST') {
|
||||||
|
# Send a test email to an address
|
||||||
|
|
||||||
|
$API_mailsettings->checkPermissions('admin-mailsettings', 'RO');
|
||||||
|
|
||||||
|
$requiredFields = [
|
||||||
|
'mail_to' => ['type' => 'email'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$API_mailsettings->validateData($requiredFields);
|
||||||
|
|
||||||
|
# Send the test email
|
||||||
|
$mailBuilder = new mailBuilder();
|
||||||
|
$API_mailsettings->testSendMail($mailBuilder);
|
||||||
|
|
||||||
|
$API_mailsettings->apiOutput(200, ['success' => 'The test email was sent.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -218,6 +218,10 @@ return [
|
|||||||
'mfa_disabled' => 'Two factor authentication is disabled.',
|
'mfa_disabled' => 'Two factor authentication is disabled.',
|
||||||
'send_password_reset' => 'Send password reset email',
|
'send_password_reset' => 'Send password reset email',
|
||||||
'email_send' => 'Email sent',
|
'email_send' => 'Email sent',
|
||||||
|
'send_test_mail' => 'Send test email',
|
||||||
|
'send_test_mail_explanation' => 'This test will send an email to the given email address.',
|
||||||
|
'send_mail' => 'Sent',
|
||||||
|
'mail_to' => 'Mail to',
|
||||||
'api_token_created' => 'API token created',
|
'api_token_created' => 'API token created',
|
||||||
'permission_created' => 'Permission created',
|
'permission_created' => 'Permission created',
|
||||||
'permission_updated' => 'Permission updated',
|
'permission_updated' => 'Permission updated',
|
||||||
@@ -242,6 +246,7 @@ return [
|
|||||||
'inserve_url' => 'Inserve URL',
|
'inserve_url' => 'Inserve URL',
|
||||||
'inserve_source' => 'Inserve Configuration',
|
'inserve_source' => 'Inserve Configuration',
|
||||||
'test_connection' => 'Test Connection',
|
'test_connection' => 'Test Connection',
|
||||||
|
'test' => 'Test',
|
||||||
'connection_success_title' => 'Successful',
|
'connection_success_title' => 'Successful',
|
||||||
'connection_success_text' => 'Connection made successful',
|
'connection_success_text' => 'Connection made successful',
|
||||||
'connection_error_title' => 'Error',
|
'connection_error_title' => 'Error',
|
||||||
|
|||||||
@@ -218,6 +218,10 @@ return [
|
|||||||
'mfa_disabled' => 'Two factor authenticatie is uitgeschakeld',
|
'mfa_disabled' => 'Two factor authenticatie is uitgeschakeld',
|
||||||
'send_password_reset' => 'Wachtwoord herstel e-mail versturen',
|
'send_password_reset' => 'Wachtwoord herstel e-mail versturen',
|
||||||
'email_send' => 'Verstuur e-mail',
|
'email_send' => 'Verstuur e-mail',
|
||||||
|
'send_test_mail' => 'Verstuur test e-mail',
|
||||||
|
'send_test_mail_explanation' => 'Deze test verstuurd een e-mail naar het opgegeven adres.',
|
||||||
|
'send_mail' => 'Verstuur',
|
||||||
|
'mail_to' => 'Mail naar',
|
||||||
'api_token_created' => 'API token toegevoegd',
|
'api_token_created' => 'API token toegevoegd',
|
||||||
'permission_created' => 'Permission aangemaakt',
|
'permission_created' => 'Permission aangemaakt',
|
||||||
'permission_updated' => 'Permission bijgewerkt',
|
'permission_updated' => 'Permission bijgewerkt',
|
||||||
@@ -242,6 +246,7 @@ return [
|
|||||||
'inserve_url' => 'Inserve URL',
|
'inserve_url' => 'Inserve URL',
|
||||||
'inserve_source' => 'Inserve Configuratie',
|
'inserve_source' => 'Inserve Configuratie',
|
||||||
'test_connection' => 'Test Connectie',
|
'test_connection' => 'Test Connectie',
|
||||||
|
'test' => 'Test',
|
||||||
'connection_success_title' => 'Success',
|
'connection_success_title' => 'Success',
|
||||||
'connection_success_text' => 'Connectie succesvol',
|
'connection_success_text' => 'Connectie succesvol',
|
||||||
'connection_error_title' => 'Error',
|
'connection_error_title' => 'Error',
|
||||||
|
|||||||
@@ -244,6 +244,9 @@ while ($module = $system_modules_data->fetch_assoc()) {
|
|||||||
<div class="card-footer py-4">
|
<div class="card-footer py-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col d-flex justify-content-end">
|
<div class="col d-flex justify-content-end">
|
||||||
|
<a href="#" class="btn btn-success mx-2" data-bs-toggle="modal" data-bs-target="#testMailModal">
|
||||||
|
<i class="fa-solid fa-envelope-circle-check"></i> <?php echo __('test') ?>
|
||||||
|
</a>
|
||||||
<?php if ($API->checkPermissions('admin-mailsettings', 'RW', true)) { ?>
|
<?php if ($API->checkPermissions('admin-mailsettings', 'RW', true)) { ?>
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
<i class="fas fa-edit"></i> <?php echo __('edit') ?>
|
<i class="fas fa-edit"></i> <?php echo __('edit') ?>
|
||||||
@@ -253,6 +256,42 @@ while ($module = $system_modules_data->fetch_assoc()) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div class="modal fade" id="testMailModal" tabindex="-1" aria-labelledby="infoModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||||
|
<div class="modal-content bg-black2">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="infoModalLabel">
|
||||||
|
<i class="fa-solid fa-envelope-circle-check"></i> <?php echo __('send_test_mail') ?>
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>
|
||||||
|
<?php echo __('send_test_mail_explanation') ?>
|
||||||
|
</p>
|
||||||
|
<form id="FormValidation" method="post" action="/api/v1/portal-management/mail/test/">
|
||||||
|
<input type="hidden" name="portal_uuid" value="<?php echo $portal_settings['portal_uuid']; ?>">
|
||||||
|
<input type="hidden" name="_method" value="POST">
|
||||||
|
<input type="hidden" name="_return" value="/systemconfig/#mail-settings">
|
||||||
|
<div class="form-group form-show-validation row">
|
||||||
|
<label for="mail_to" class="col-lg-3 col-md-3 col-sm-4 mt-sm-2"><?php echo __('mail_to') ?>:</label>
|
||||||
|
<div class="col-lg-9 col-md-12 col-sm-10">
|
||||||
|
<input type="email" class="form-control" id="mail_to" name="mail_to" value="" placeholder="Send test mail to..." required/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr class="text-light">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col d-flex justify-content-end">
|
||||||
|
<button type="submit" class="btn btn-success">
|
||||||
|
<i class="fa-solid fa-paper-plane"></i> <?php echo __('send_mail') ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user