diff --git a/apxtri/models/Notifications.js b/apxtri/models/Notifications.js index 57057a9..ffbc44e 100644 --- a/apxtri/models/Notifications.js +++ b/apxtri/models/Notifications.js @@ -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 }; } };