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,16 +1,18 @@
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,
auth: { port: mail.transport.port,
user: process.env.MAIL__USER, secure: mail.transport.secure,
pass: process.env.MAIL__PASS, from: mail.send.from,
}, auth: {
}) user: mail.user,
pass: mail.pass,
},
})
/** /**
* @description Sends an email * @description Sends an email
@ -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>",