misc: added more error handling

This commit is contained in:
Sheen Capadngan
2024-11-08 21:43:25 +08:00
parent bf09fa33fa
commit 8a14914bc3
5 changed files with 74 additions and 14 deletions
+17 -1
View File
@@ -77,5 +77,21 @@ export const smtpServiceFactory = (cfg: TSmtpConfig) => {
}
};
return { sendMail };
const verify = async () => {
const isConnected = smtp
.verify()
.then(async () => {
logger.info("SMTP connected");
return true;
})
.catch((err: Error) => {
logger.error("SMTP error");
logger.error(err);
return false;
});
return isConnected;
};
return { sendMail, verify };
};