email setup more functions
This commit is contained in:
@@ -56,6 +56,7 @@ let adminTablesSelectedSelect;
|
||||
let adminTablesAddBtn;
|
||||
let adminTablesRemoveBtn;
|
||||
let adminLoadBridgeBtn;
|
||||
let smtpTestBtn;
|
||||
|
||||
ensureConsoleCapture();
|
||||
|
||||
@@ -86,6 +87,7 @@ export function initAccountPage() {
|
||||
adminTablesAddBtn = document.getElementById('adminBridgeTablesAdd');
|
||||
adminTablesRemoveBtn = document.getElementById('adminBridgeTablesRemove');
|
||||
adminLoadBridgeBtn = document.getElementById('btn-admin-load-bridge');
|
||||
smtpTestBtn = document.getElementById('btn-smtp-test');
|
||||
sectionsList = document.getElementById('sectionsList');
|
||||
sectionsCreateForm = document.getElementById('sectionsCreateForm');
|
||||
sectionNameInput = document.getElementById('sectionNameInput');
|
||||
@@ -140,6 +142,9 @@ export function initAccountPage() {
|
||||
adminLoadBridgeBtn?.addEventListener('click', () => {
|
||||
refreshBridgeTablesFromEndpoint();
|
||||
});
|
||||
smtpTestBtn?.addEventListener('click', () => {
|
||||
runSmtpTest();
|
||||
});
|
||||
|
||||
initSectionsManager();
|
||||
|
||||
@@ -452,7 +457,11 @@ function fillSettingsForm(settings) {
|
||||
if (settingsForm.smtp_host) settingsForm.smtp_host.value = settings.smtp_host || '';
|
||||
if (settingsForm.smtp_port) settingsForm.smtp_port.value = settings.smtp_port ? String(settings.smtp_port) : '';
|
||||
if (settingsForm.smtp_user) settingsForm.smtp_user.value = settings.smtp_user || '';
|
||||
if (settingsForm.smtp_pass) settingsForm.smtp_pass.value = settings.smtp_pass || '';
|
||||
if (settingsForm.smtp_pass) settingsForm.smtp_pass.value = '';
|
||||
if (settingsForm.smtp_pass) {
|
||||
settingsForm.smtp_pass.placeholder = settings.smtp_pass_set ? 'Passwort gesetzt' : '••••••••';
|
||||
}
|
||||
if (settingsForm.smtp_pass_clear) settingsForm.smtp_pass_clear.checked = false;
|
||||
if (settingsForm.smtp_secure) settingsForm.smtp_secure.value = settings.smtp_secure || '';
|
||||
if (settingsForm.smtp_from_email) settingsForm.smtp_from_email.value = settings.smtp_from_email || '';
|
||||
if (settingsForm.smtp_from_name) settingsForm.smtp_from_name.value = settings.smtp_from_name || '';
|
||||
@@ -518,6 +527,7 @@ async function submitSettingsForm(ev) {
|
||||
}
|
||||
if (settingsForm.smtp_user) data.smtp_user = settingsForm.smtp_user.value.trim();
|
||||
if (settingsForm.smtp_pass) data.smtp_pass = settingsForm.smtp_pass.value;
|
||||
if (settingsForm.smtp_pass_clear) data.smtp_pass_clear = settingsForm.smtp_pass_clear.checked ? 1 : 0;
|
||||
if (settingsForm.smtp_secure) data.smtp_secure = settingsForm.smtp_secure.value;
|
||||
if (settingsForm.smtp_from_email) data.smtp_from_email = settingsForm.smtp_from_email.value.trim();
|
||||
if (settingsForm.smtp_from_name) data.smtp_from_name = settingsForm.smtp_from_name.value.trim();
|
||||
@@ -558,6 +568,31 @@ async function downloadFile(type) {
|
||||
}
|
||||
}
|
||||
|
||||
async function runSmtpTest() {
|
||||
if (!settingsForm) return;
|
||||
const recipient = prompt('Test-E-Mail an welche Adresse senden?', window.__currentUser?.email || '');
|
||||
if (!recipient) return;
|
||||
const data = {
|
||||
to: recipient.trim(),
|
||||
smtp_enabled: settingsForm.smtp_enabled?.checked ? 1 : 0,
|
||||
smtp_host: settingsForm.smtp_host?.value.trim() || '',
|
||||
smtp_port: settingsForm.smtp_port?.value.trim() || '',
|
||||
smtp_user: settingsForm.smtp_user?.value.trim() || '',
|
||||
smtp_pass: settingsForm.smtp_pass?.value || '',
|
||||
smtp_secure: settingsForm.smtp_secure?.value || '',
|
||||
smtp_from_email: settingsForm.smtp_from_email?.value.trim() || '',
|
||||
smtp_from_name: settingsForm.smtp_from_name?.value.trim() || '',
|
||||
smtp_reply_to: settingsForm.smtp_reply_to?.value.trim() || '',
|
||||
};
|
||||
try {
|
||||
const res = await apiAction('account.smtp.test', { method: 'POST', data });
|
||||
if (!res?.ok) throw new Error(res?.error || 'SMTP Test fehlgeschlagen');
|
||||
toast('SMTP Test gesendet', true);
|
||||
} catch (err) {
|
||||
toast(err.message || 'SMTP Test fehlgeschlagen', false);
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeTableList(input) {
|
||||
const items = Array.isArray(input) ? input : (typeof input === 'string' ? input.split(/[\s,]+/) : []);
|
||||
const result = [];
|
||||
|
||||
Reference in New Issue
Block a user