18 lines
521 B
TypeScript
18 lines
521 B
TypeScript
|
import nodemailer from 'nodemailer'
|
||
|
|
||
|
export default class EmailService {
|
||
|
static getTransporter() {
|
||
|
if (process.env.SMTP_HOST == undefined || process.env.SMTP_PORT == undefined) {
|
||
|
throw new Error("Invalid SMTP config")
|
||
|
}
|
||
|
return nodemailer.createTransport({
|
||
|
host: process.env.SMTP_HOST,
|
||
|
port: parseInt(process.env.SMTP_PORT),
|
||
|
secure: process.env.SMTP_SECURE == 'true',
|
||
|
auth: {
|
||
|
user: process.env.SMTP_USERNAME,
|
||
|
pass: process.env.SMTP_PASSWORD,
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|