mirror of
https://github.com/gnmyt/LicenseAPI.git
synced 2026-01-10 10:11:47 +00:00
Create email.ts util
This commit is contained in:
20
src/utils/email.ts
Normal file
20
src/utils/email.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { createTransport, SentMessageInfo } from "nodemailer";
|
||||
import { Options } from "nodemailer/lib/mailer";
|
||||
import * as process from "process";
|
||||
|
||||
const transport = createTransport({
|
||||
host: process.env.MAIL_SERVER || "smtp.gmail.com",
|
||||
port: parseInt(process.env.MAIL_PORT || "587"),
|
||||
auth: {
|
||||
user: process.env.MAIL_USER || "noreply@licenseapi.de",
|
||||
pass: process.env.MAIL_PASS,
|
||||
},
|
||||
});
|
||||
|
||||
export const sendMail = (options: Options, success?: (info: SentMessageInfo) => void, error?: (msg: Error) => void) => transport.sendMail({
|
||||
...options, from: process.env.MAIL_USER || "noreply@licenseapi.de",
|
||||
}, (err, info) => {
|
||||
if (err !== null && error) return error(err);
|
||||
|
||||
if (success) success(info);
|
||||
});
|
||||
Reference in New Issue
Block a user