|
|
@ -238,7 +238,7 @@ Emailer.send = async (template, uid, params) => {
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
winston.warn(`uid : ${uid} has no email, not sending "${template}" email.`);
|
|
|
|
winston.warn(`uid : ${uid} has no email, not sending "${template}" email.`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const allowedTpls = ['verify-email', 'welcome', 'registration_accepted', 'reset', 'reset_notify'];
|
|
|
|
const allowedTpls = ['verify-email', 'welcome', 'registration_accepted', 'reset', 'reset_notify'];
|
|
|
@ -246,7 +246,7 @@ Emailer.send = async (template, uid, params) => {
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
winston.warn(`uid : ${uid} (${userData.email}) has not confirmed email, not sending "${template}" email.`);
|
|
|
|
winston.warn(`uid : ${uid} (${userData.email}) has not confirmed email, not sending "${template}" email.`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const userSettings = await User.getSettings(uid);
|
|
|
|
const userSettings = await User.getSettings(uid);
|
|
|
|
// Combined passed-in payload with default values
|
|
|
|
// Combined passed-in payload with default values
|
|
|
@ -262,10 +262,9 @@ Emailer.send = async (template, uid, params) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (result.cancel) {
|
|
|
|
if (result.cancel) {
|
|
|
|
return false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await Emailer.sendToEmail(template, userData.email, userSettings.userLang, params);
|
|
|
|
return Emailer.sendToEmail(template, userData.email, userSettings.userLang, params);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Emailer.sendToEmail = async (template, email, language, params) => {
|
|
|
|
Emailer.sendToEmail = async (template, email, language, params) => {
|
|
|
@ -340,17 +339,13 @@ Emailer.sendToEmail = async (template, email, language, params) => {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
await Emailer.sendViaFallback(data);
|
|
|
|
await Emailer.sendViaFallback(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
if (err.code === 'ENOENT' && usingFallback) {
|
|
|
|
if (err.code === 'ENOENT' && usingFallback) {
|
|
|
|
Emailer.fallbackNotFound = true;
|
|
|
|
Emailer.fallbackNotFound = true;
|
|
|
|
winston.error(`[emailer/sendToEmail] ${await translator.translate('[[error:sendmail-not-found]]')}`);
|
|
|
|
throw new Error('[[error:sendmail-not-found]]');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
winston.error(`[emailer/sendToEmail] ${err.message || err.code || 'Unknown error while sending email.'}`);
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -365,7 +360,6 @@ Emailer.sendViaFallback = async (data) => {
|
|
|
|
|
|
|
|
|
|
|
|
winston.verbose(`[emailer] Sending email to uid ${data.uid} (${data.to})`);
|
|
|
|
winston.verbose(`[emailer] Sending email to uid ${data.uid} (${data.to})`);
|
|
|
|
await Emailer.fallbackTransport.sendMail(data);
|
|
|
|
await Emailer.fallbackTransport.sendMail(data);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Emailer.renderAndTranslate = async (template, params, lang) => {
|
|
|
|
Emailer.renderAndTranslate = async (template, params, lang) => {
|
|
|
|