Files
Docwell/Server/admin/src/views/EmailView.vue
T
tajniak81andClaude Opus 5.5 b9be8be156
CI / go (Server) (push) Failing after 22m50s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 8m47s
CI / desktop (ubuntu-latest) (push) Successful in 2h56m50s
CI / mobile (push) Failing after 5m33s
CI / docker (push) Successful in 1h43m8s
Docs / build (push) Successful in 16m2s
Docs / deploy (push) Skipped
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
Run docwell-db as a stock PocketBase and let the server set it up
docwell-db no longer needs a Docwell image: the stack runs
tajniak81/pocketbase-docker-root as it is, and docwell-server does what
the migrations and pb_hooks used to do inside PocketBase.

On start, docwell-server now:
- waits for PocketBase and imports Docwell's collections from an
  embedded snapshot (internal/pbschema). Existing collections and
  fields are matched by name, so their data is kept; the admin-managed
  users options (OAuth2 providers, magic link) are left untouched.
- writes the DOCWELL_APP_NAME, DOCWELL_WEB_URL, DOCWELL_MAIL_FROM,
  DOCWELL_SMTP_* and DOCWELL_S3_* settings into PocketBase, as the
  boot hook did.

It also replaces the hook's two routes: token checks use PocketBase's
auth-refresh (the organization name is read as the superuser), and
Docwell's own emails go out over SMTP from the server. PocketBase never
returns the SMTP password, so the server keeps a copy in the
superuser-only instance_settings collection; a password saved before
this change has to be entered once more in the admin panel.

Database/ keeps pb_migrations as the source of the schema;
export-schema.sh regenerates the snapshot from them. Database/Dockerfile
and pb_hooks are removed, the release no longer builds docwell-db, the
AIO image runs PocketBase without migrations or hooks, and the compose
files default DB_IMAGE to the stock image and pass the settings to the
server instead of the database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:09:38 +01:00

113 lines
4.4 KiB
Vue

<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
<script setup lang="ts">
import { DwButton, DwCallout } from "@docwell/ui";
import { reactive, ref, watch } from "vue";
import { useInstanceSettings } from "../settings";
import { api, currentUser, errorMessage } from "../session";
// Outgoing mail: verification, password reset, invites and sign-in links.
const { settings, error, saved, busy, save } = useInstanceSettings();
const form = reactive({
enabled: false,
host: "",
port: 587,
username: "",
password: "",
tls: false,
senderName: "",
senderAddress: "",
});
const testTo = ref("");
const testState = ref<{ ok: boolean; text: string } | null>(null);
watch(settings, (s) => {
if (!s) return;
Object.assign(form, { ...s.smtp, password: "" });
testTo.value ||= currentUser.value?.email ?? "";
});
function submit() {
// An empty password keeps the stored one.
const { password, ...rest } = form;
save({ smtp: { ...rest, passwordSet: false, ...(password ? { password } : {}) } });
}
async function sendTest() {
testState.value = null;
try {
await api.settings.testEmail(testTo.value);
testState.value = { ok: true, text: `Sent to ${testTo.value}. Check the inbox (and the spam folder).` };
} catch (e) {
testState.value = { ok: false, text: errorMessage(e) };
}
}
</script>
<template>
<h1 class="text-2xl font-semibold tracking-tight">Email</h1>
<p class="mt-1 text-ink-muted">
Docwell sends verification, password reset, invite and sign-in emails through this server.
</p>
<DwCallout v-if="error" tone="danger" size="ui" class="mt-4">{{ error }}</DwCallout>
<DwCallout v-if="saved" tone="success" size="ui" class="mt-4">Saved.</DwCallout>
<DwCallout size="ui" class="mt-4 max-w-xl">
If DOCWELL_SMTP_HOST is set for docwell-server, those environment values are applied again whenever it starts.
</DwCallout>
<form v-if="settings" class="mt-6 grid max-w-xl gap-4 dw-card sm:grid-cols-2" @submit.prevent="submit">
<label class="flex items-center gap-3 sm:col-span-2">
<input v-model="form.enabled" type="checkbox" class="accent-primary" />
<span class="font-medium">Send email through an SMTP server</span>
</label>
<label class="flex flex-col gap-1.5">
<span class="text-ui-sm font-semibold">Host</span>
<input v-model="form.host" :required="form.enabled" class="dw-input" placeholder="smtp.example.com" />
</label>
<label class="flex flex-col gap-1.5">
<span class="text-ui-sm font-semibold">Port</span>
<input v-model.number="form.port" type="number" min="1" max="65535" class="dw-input" />
</label>
<label class="flex flex-col gap-1.5">
<span class="text-ui-sm font-semibold">Username</span>
<input v-model="form.username" autocomplete="off" class="dw-input" />
</label>
<label class="flex flex-col gap-1.5">
<span class="text-ui-sm font-semibold">Password</span>
<input
v-model="form.password"
type="password"
autocomplete="new-password"
class="dw-input"
:placeholder="settings.smtp.passwordSet ? 'Unchanged' : ''"
/>
</label>
<label class="flex items-center gap-3 sm:col-span-2">
<input v-model="form.tls" type="checkbox" class="accent-primary" />
<span>Use TLS from the start (usually port 465; port 587 upgrades on its own)</span>
</label>
<label class="flex flex-col gap-1.5">
<span class="text-ui-sm font-semibold">Sender name</span>
<input v-model="form.senderName" class="dw-input" />
</label>
<label class="flex flex-col gap-1.5">
<span class="text-ui-sm font-semibold">Sender address</span>
<input v-model="form.senderAddress" type="email" required class="dw-input" />
</label>
<div class="sm:col-span-2">
<DwButton type="submit" variant="primary" :disabled="busy">Save</DwButton>
</div>
</form>
<section v-if="settings" class="mt-6 max-w-xl dw-card">
<h2 class="text-ui-lg">Test</h2>
<p class="mt-1 text-ui-sm text-ink-muted">Sends a short email with the saved settings.</p>
<form class="mt-3 flex flex-wrap gap-2" @submit.prevent="sendTest">
<input v-model="testTo" type="email" required class="dw-input min-w-48 flex-1" aria-label="Send the test to" />
<DwButton type="submit">Send test email</DwButton>
</form>
<DwCallout v-if="testState" :tone="testState.ok ? 'success' : 'danger'" size="ui" class="mt-3">
{{ testState.text }}
</DwCallout>
</section>
</template>