Created the mail util
This commit is contained in:
parent
4afaa8ae32
commit
34530e1682
19
src/utils/email.ts
Normal file
19
src/utils/email.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { createTransport, SentMessageInfo } from "nodemailer";
|
||||
import { Options } from "nodemailer/lib/mailer";
|
||||
import * as process from "process";
|
||||
|
||||
const transport = createTransport({
|
||||
service: process.env.MAIL_SERVICE || "gmail",
|
||||
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.USER || "noreply@licenseapi.de",
|
||||
}, (err, info) => {
|
||||
if (err !== null && error) return error(err);
|
||||
|
||||
if (success) success(info);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user