feat: Add flatrate billing model for editorial accounts
This commit is contained in:
1 parent
699580a6a0
commit
0b1ffdfdfc
39 files changed
+4900
-57
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import "server-only";
|
||||
import nodemailer from "nodemailer";
|
||||
import { env } from "@/config/env";
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: env.SMTP_HOST,
|
||||
port: env.SMTP_PORT,
|
||||
secure: env.SMTP_PORT === 465,
|
||||
auth: {
|
||||
user: env.SMTP_USER,
|
||||
pass: env.SMTP_PASSWORD,
|
||||
},
|
||||
});
|
||||
|
||||
export const emailService = {
|
||||
async sendBillingReport(toEmail: string, reportMonth: string, pdfBytes: Buffer, invoiceNumber: string) {
|
||||
const filename = invoiceNumber.replace(/[^A-Za-z0-9_-]/g, "_") + ".pdf";
|
||||
|
||||
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`,
|
||||
attachments: [
|
||||
{
|
||||
filename,
|
||||
content: pdfBytes,
|
||||
contentType: "application/pdf",
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
|
||||
async sendNewAlbumNotification(toEmail: string, albumName: string) {
|
||||
await transporter.sendMail({
|
||||
from: env.SMTP_FROM,
|
||||
to: toEmail,
|
||||
subject: `Neues Fotoalbum verfügbar: ${albumName}`,
|
||||
text: `Hallo,\n\nein neues Fotoalbum "${albumName}" wurde für Ihre Redaktion freigegeben. Sie können die Bilder ab sofort im Redaktionsportal ansehen und lizenzieren.\n\nViele Grüße,\nIhr Redaktions-Team`,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user