manage error log for email sender

This commit is contained in:
philc 2024-12-17 16:29:22 +01:00
parent 2ac8704f55
commit 04efb9f00c

View File

@ -346,6 +346,7 @@ Notifications.sendmail = async (data, tribe) => {
confsmtp = conftrib.smtp;
if (!data.from || data.from == conf.emailcontact) data.from = conftrib.emailcontact;
}
// console.log(confsmtp)
const transporter = await nodemailer.createTransport(confsmtp);
if (data.filelist) {
data.attachments = [];
@ -365,10 +366,16 @@ Notifications.sendmail = async (data, tribe) => {
};
}
//console.log("data:", data);
const res = await transporter.sendMail(data);
//console.log(res)
let res;
let error;
try{
res = await transporter.sendMail(data);
}catch(err){
console.log(err)
error=err
}
if (
res.accepted &&
res && res.accepted &&
data.to.split(",").reduce((acc, m) => acc && res.accepted.includes(m), true)
) {
data.accepted = res.accepted;
@ -379,12 +386,12 @@ Notifications.sendmail = async (data, tribe) => {
msg: "successfullsentemail",
data,
};
} else if (res.accepted && res.rejected) {
} else if ( res && res.accepted && res.rejected) {
data.accepted = res.accepted;
data.rejected = res.rejected;
return { status: 410, ref: "Notifications", msg: "errsendmail", data };
} else {
data.errmailer = res.err;
data.errmailer = error;
return { status: 417, ref: "Notifications", msg: "errsendmail", data };
}
};