mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
setup STMP from .env
This commit is contained in:
@ -11,14 +11,29 @@ export const sendMail = async (
|
||||
content: string | Buffer;
|
||||
}[] = []
|
||||
) => {
|
||||
if (!process.env.SENDGRID_API_KEY)
|
||||
throw new Error("Sendgrid API Key not set.");
|
||||
let transport;
|
||||
if (process.env.SENDGRID_API_KEY)
|
||||
transport = nodemailer.createTransport(
|
||||
nodemailerSendgrid({
|
||||
apiKey: process.env.SENDGRID_API_KEY || "",
|
||||
})
|
||||
);
|
||||
|
||||
if (process.env.SMTP_MAIL_HOST)
|
||||
transport = nodemailer.createTransport({
|
||||
host: process.env.SMTP_MAIL_HOST || "",
|
||||
port: Number(process.env.SMTP_MAIL_PORT) || 587,
|
||||
auth: {
|
||||
user: process.env.SMTP_MAIL_USER || "",
|
||||
pass: process.env.SMTP_MAIL_PASSWORD || "",
|
||||
},
|
||||
});
|
||||
|
||||
if (!transport)
|
||||
throw new Error(
|
||||
"No valid transport for NodeMailer found. Probably Sendgrid API Key nor SMTP Mail host was set."
|
||||
);
|
||||
|
||||
const transport = await nodemailer.createTransport(
|
||||
nodemailerSendgrid({
|
||||
apiKey: process.env.SENDGRID_API_KEY || "",
|
||||
})
|
||||
);
|
||||
await transport
|
||||
.sendMail({
|
||||
from: process.env.MAIL_FROM,
|
||||
|
||||
Reference in New Issue
Block a user