mail.ts uses unified config

This commit is contained in:
cirroskais 2024-04-28 03:41:38 -04:00
parent 21329458e5
commit 9fba6b15e8
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D

View file

@ -1,14 +1,16 @@
import { createTransport } from "nodemailer" import { createTransport } from "nodemailer"
import "dotenv/config" import config from "./config.js"
import config from "../../../config.json" assert { type: "json" }
import { generateFileId } from "./files.js" import { generateFileId } from "./files.js"
let mailConfig = config.mail, const { mail } = config
transport = createTransport({ const transport = createTransport({
...mailConfig.transport, host: mail.transport.host,
port: mail.transport.port,
secure: mail.transport.secure,
from: mail.send.from,
auth: { auth: {
user: process.env.MAIL__USER, user: mail.user,
pass: process.env.MAIL__PASS, pass: mail.pass,
}, },
}) })
@ -23,7 +25,6 @@ export function sendMail(to: string, subject: string, content: string) {
return transport.sendMail({ return transport.sendMail({
to, to,
subject, subject,
from: mailConfig.send.from,
html: `<span style="font-size:x-large;font-weight:600;">monofile <span style="opacity:0.5">accounts</span></span><br><span style="opacity:0.5">Gain control of your uploads.</span><hr><br>${content html: `<span style="font-size:x-large;font-weight:600;">monofile <span style="opacity:0.5">accounts</span></span><br><span style="opacity:0.5">Gain control of your uploads.</span><hr><br>${content
.replaceAll( .replaceAll(
"<span username>", "<span username>",