Add SMTP status check
This commit is contained in:
15
helpers/smtpStatus.js
Normal file
15
helpers/smtpStatus.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const smtpTransporter = require('./smtpTransporter');
|
||||
|
||||
function smtpStatus() {
|
||||
smtpTransporter.verify(function (error, success) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
return `SMTP is not working, check your configuration.`
|
||||
} else {
|
||||
console.log('Server is ready to take our messages');
|
||||
return `SMTP is correctly configured.`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = smtpStatus;
|
||||
@@ -6,15 +6,20 @@ const {
|
||||
smtpPort,
|
||||
smtpUsername,
|
||||
smtpPassword,
|
||||
smtpSecure,
|
||||
smtpRequireTLS,
|
||||
} = require('../config/config');
|
||||
|
||||
nodemailer.createTransport({
|
||||
const smtpTransporter = nodemailer.createTransport({
|
||||
pool: smtpPool,
|
||||
host: smtpHost,
|
||||
port: smtpPort,
|
||||
requireTLS: smtpRequireTLS,
|
||||
secure: smtpSecure,
|
||||
auth: {
|
||||
user: smtpUsername,
|
||||
pass: smtpPassword,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = smtpTransporter;
|
||||
|
||||
Reference in New Issue
Block a user