server/src/EmailService.ts

18 lines
521 B
TypeScript
Raw Normal View History

2020-07-10 20:44:01 +00:00
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,
}
})
}
}