do not pass smtp user/pass to nodemailer if both are empty

This commit is contained in:
LouisLam 2021-08-17 01:26:21 +08:00
parent fc76c2836b
commit 31d5b4fd3d

View file

@ -197,9 +197,9 @@ class Notification {
try {
let config = {
headers: {
'api-key': notification.octopushAPIKey,
'api-login': notification.octopushLogin,
'cache-control': 'no-cache'
"api-key": notification.octopushAPIKey,
"api-login": notification.octopushLogin,
"cache-control": "no-cache"
}
};
let data = {
@ -215,7 +215,7 @@ class Notification {
"sender": notification.octopushSenderName
};
await axios.post(`https://api.octopush.com/v1/public/sms-campaign/send`, data, config)
await axios.post("https://api.octopush.com/v1/public/sms-campaign/send", data, config)
return true;
} catch (error) {
console.log(error)
@ -356,11 +356,11 @@ class Notification {
} else if (notification.type === "pushbullet") {
try {
let pushbulletUrl = `https://api.pushbullet.com/v2/pushes`;
let pushbulletUrl = "https://api.pushbullet.com/v2/pushes";
let config = {
headers: {
'Access-Token': notification.pushbulletAccessToken,
'Content-Type': 'application/json'
"Access-Token": notification.pushbulletAccessToken,
"Content-Type": "application/json"
}
};
if (heartbeatJSON == null) {
@ -432,15 +432,21 @@ class Notification {
static async smtp(notification, msg) {
let transporter = nodemailer.createTransport({
const config = {
host: notification.smtpHost,
port: notification.smtpPort,
secure: notification.smtpSecure,
auth: {
};
// Should fix the issue in https://github.com/louislam/uptime-kuma/issues/26#issuecomment-896373904
if (notification.smtpUsername || notification.smtpPassword) {
config.auth = {
user: notification.smtpUsername,
pass: notification.smtpPassword,
},
});
};
}
let transporter = nodemailer.createTransport(config);
// send mail with defined transport object
await transporter.sendMail({