fix: #9339, only log email errors once per digest, notification push

show notice in acp
This commit is contained in:
Barış Soner Uşaklı
2021-03-05 19:03:16 -05:00
parent 3f42d40c78
commit 3aa26c4df2
6 changed files with 35 additions and 7 deletions

View File

@@ -25,6 +25,8 @@ const Emailer = module.exports;
let prevConfig;
let app;
Emailer.fallbackNotFound = false;
Emailer.transports = {
sendmail: nodemailer.createTransport({
sendmail: true,
@@ -312,7 +314,8 @@ Emailer.sendToEmail = async (template, email, language, params) => {
headers: params.headers,
rtl: params.rtl,
});
const usingFallback = !Plugins.hooks.hasListeners('filter:email.send') &&
!Plugins.hooks.hasListeners('static:email.send');
try {
if (Plugins.hooks.hasListeners('filter:email.send')) {
// Deprecated, remove in v1.18.0
@@ -323,7 +326,8 @@ Emailer.sendToEmail = async (template, email, language, params) => {
await Emailer.sendViaFallback(data);
}
} catch (err) {
if (err && err.code === 'ENOENT') {
if (err.code === 'ENOENT' && usingFallback) {
Emailer.fallbackNotFound = true;
throw new Error('[[error:sendmail-not-found]]');
} else {
throw err;