fix: harden production flows and user messaging
This commit is contained in:
1 parent
52dce168dd
commit
86dfe8053d
43 files changed
+3520
-358
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import "server-only";
|
||||
import nodemailer from "nodemailer";
|
||||
import { env } from "@/config/env";
|
||||
import { billingReportMessage } from "./billing-report-message";
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: env.SMTP_HOST,
|
||||
@@ -74,14 +75,15 @@ function buildHtml(title: string, content: string, button?: { text: string, url:
|
||||
|
||||
export const emailService = {
|
||||
async sendBillingReport(toEmail: string, reportMonth: string, pdfBytes: Buffer, invoiceNumber: string) {
|
||||
const filename = invoiceNumber.replace(/[^A-Za-z0-9_-]/g, "_") + ".pdf";
|
||||
const filename = "Nutzungsnachweis-" + invoiceNumber.replace(/[^A-Za-z0-9_-]/g, "_") + ".pdf";
|
||||
const message = billingReportMessage(reportMonth);
|
||||
|
||||
await transporter.sendMail({
|
||||
from: env.SMTP_FROM,
|
||||
to: toEmail,
|
||||
subject: `Ihre Abrechnung für ${reportMonth}`,
|
||||
text: `Hallo,\n\nanbei erhalten Sie Ihre Abrechnung für den Monat ${reportMonth} als PDF-Dokument.\n\nViele Grüße,\nIhr Redaktions-Team`,
|
||||
html: buildHtml("Ihre Abrechnung ist da", `Hallo,\n\nanbei erhalten Sie Ihre Abrechnung für den Monat **${reportMonth}** bequem als PDF-Dokument angehängt.\n\nViele Grüße,\nIhr Redaktions-Team`),
|
||||
subject: message.subject,
|
||||
text: message.text,
|
||||
html: buildHtml("Ihr Nutzungsnachweis", message.htmlContent),
|
||||
attachments: [
|
||||
{
|
||||
filename,
|
||||
|
||||
Reference in new issue
Block a user