Upload via GUI (16 Dateien)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// mailer.js — sends mail through the practice's own SMTP account (their normal
|
||||
// mailbox + an app password, entered once in Einstellungen). No third-party email
|
||||
// service involved; credentials are stored in the shared data folder's database,
|
||||
// same trust model as the folder path itself.
|
||||
"use strict";
|
||||
|
||||
const nodemailer = require("nodemailer");
|
||||
|
||||
function buildTransport(smtp) {
|
||||
return nodemailer.createTransport({
|
||||
host: smtp.host,
|
||||
port: Number(smtp.port) || 587,
|
||||
secure: !!smtp.secure,
|
||||
auth: smtp.user ? { user: smtp.user, pass: smtp.pass } : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
async function verifySmtp(smtp) {
|
||||
const transporter = buildTransport(smtp);
|
||||
await transporter.verify();
|
||||
}
|
||||
|
||||
async function sendMail(smtp, { to, subject, text, attachments }) {
|
||||
const transporter = buildTransport(smtp);
|
||||
const fromAddress = smtp.fromEmail || smtp.user;
|
||||
await transporter.sendMail({
|
||||
from: smtp.fromName ? `"${smtp.fromName}" <${fromAddress}>` : fromAddress,
|
||||
to,
|
||||
subject,
|
||||
text,
|
||||
attachments,
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { verifySmtp, sendMail };
|
||||
Reference in New Issue
Block a user