Files
pfandsystem-demo/backend/lib/mail.js

33 lines
1.5 KiB
JavaScript
Raw Normal View History

import { Resend } from 'resend';
const resend = process.env.RESEND_API_KEY ? new Resend(process.env.RESEND_API_KEY) : null;
const FROM = process.env.MAIL_FROM || 'Pfandsystem Demo <demo@dockly.de>';
export async function sendDemoInviteMail({ to, name, slug, password, loginUrl, days }) {
if (!resend) {
console.log('[mail-dev] Demo-Invite an', to, 'Slug:', slug, 'Pw:', password);
return { dev: true };
}
const html = `
<div style="font-family:system-ui,Segoe UI,Helvetica,Arial,sans-serif;max-width:560px;margin:auto">
<h2 style="color:#1e293b">Willkommen im Pfandsystem-Demo</h2>
<p>Hallo ${name},</p>
<p>dein <strong>${days}-Tage Demo-Zugang</strong> ist bereit. Du kannst alle Funktionen
in Ruhe testen und eigene Beispieldaten anlegen.</p>
<div style="background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;padding:16px;margin:16px 0">
<p style="margin:4px 0"><strong>Login-URL:</strong> <a href="${loginUrl}">${loginUrl}</a></p>
<p style="margin:4px 0"><strong>E-Mail:</strong> ${to}</p>
<p style="margin:4px 0"><strong>Passwort:</strong> <code>${password}</code></p>
<p style="margin:4px 0"><strong>Tenant-Kennung:</strong> ${slug}</p>
</div>
<p>Bitte aendere dein Passwort nach dem ersten Login.</p>
<p style="color:#64748b;font-size:12px">Diese Mail wurde automatisch versandt vom Pfandsystem-Demo-Portal.</p>
</div>`;
return resend.emails.send({
from: FROM,
to,
subject: `Dein Pfandsystem-Demo-Zugang (${days} Tage)`,
html
});
}