Implement test mail sending

This commit is contained in:
Johannes Zellner
2025-04-22 16:42:07 +02:00
parent 2db34c4d7e
commit daac71ac9a

View File

@@ -14,10 +14,12 @@ import MailRelaySettingsItem from '../components/MailRelaySettingsItem.vue';
import DashboardModel from '../models/DashboardModel.js';
import DomainsModel from '../models/DomainsModel.js';
import MailModel from '../models/MailModel.js';
import ProfileModel from '../models/ProfileModel.js';
const dashboardModel = DashboardModel.create();
const domainsModel = DomainsModel.create();
const mailModel = MailModel.create();
const profileModel = ProfileModel.create();
const inputDialog = useTemplateRef('inputDialog');
const enableIncomingDialog = useTemplateRef('enableIncomingDialog');
@@ -37,12 +39,14 @@ const inboundEnabled = ref(false);
const outboundEnabled = ref(false);
const usage = ref(0);
// TODO
async function onSendTestMail(domain) {
async function onSendTestMail() {
const [error, result] = await profileModel.get();
if (error) return console.error(error);
const address = await inputDialog.value.prompt({
value: profile.value.email,
title: t('emails.testMailDialog.title', { domain: domain.domain }),
message: t('emails.testMailDialog.description', { domain: domain.domain }),
value: result.email,
title: t('emails.testMailDialog.title', { domain: domain.value }),
message: t('emails.testMailDialog.description', { domain: domain.value }),
confirmLabel: t('emails.testMailDialog.sendAction'),
rejectLabel: t('main.dialog.cancel'),
rejectStyle: 'secondary'
@@ -50,10 +54,10 @@ async function onSendTestMail(domain) {
if (!address) return;
const [error] = await mailModel.sendTestMail(domain.domain, address);
if (error) {
window.pankow.notify({ text: error.body ? error.body.message : 'Failed to send mail', type: 'danger' });
return console.error(error);
const [sendError] = await mailModel.sendTestMail(domain.value, address);
if (sendError) {
window.pankow.notify({ text: sendError.body ? sendError.body.message : 'Failed to send mail', type: 'danger' });
return console.error(sendError);
}
window.pankow.notify({ text: 'Mail sent', type: 'success' });
@@ -303,6 +307,10 @@ onMounted(async () => {
</Section>
<Section title="Sending" :padding="false" v-if="!busyRefresh">
<template #header-buttons>
<Button @click="onSendTestMail">{{ $t('emails.domains.testEmailTooltip') }}</Button>
</template>
<MailRelaySettingsItem v-if="domain" :domain="domain"/>
<SettingsItem>