42 lines
793 B
JavaScript
42 lines
793 B
JavaScript
const nodemailer = require('nodemailer');
|
|
|
|
const {
|
|
smtpPool,
|
|
smtpHost,
|
|
smtpPort,
|
|
smtpUsername,
|
|
smtpPassword,
|
|
smtpSecure,
|
|
smtpRequireTLS,
|
|
} = require('../../config/config');
|
|
|
|
let mailConfig;
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
// all emails are delivered to destination
|
|
mailConfig = {
|
|
pool: smtpPool,
|
|
host: smtpHost,
|
|
port: smtpPort,
|
|
requireTLS: smtpRequireTLS,
|
|
secure: smtpSecure,
|
|
auth: {
|
|
user: smtpUsername,
|
|
pass: smtpPassword,
|
|
},
|
|
};
|
|
} else {
|
|
// all emails are catched by ethereal.email
|
|
// Check test emails: https://ethereal.email/login
|
|
mailConfig = {
|
|
host: 'smtp.ethereal.email',
|
|
port: 587,
|
|
auth: {
|
|
user: 'lemuel.wunsch91@ethereal.email',
|
|
pass: 'Y9Vs51v27Q9X9feJgN',
|
|
},
|
|
};
|
|
}
|
|
|
|
module.exports = nodemailer.createTransport(mailConfig);
|