Add safety check to disable email authentication when not required

This commit is contained in:
Alfredo Cardigliano 2022-04-12 14:38:10 +02:00
parent 2c18293ace
commit 32635385fe

View file

@ -109,7 +109,14 @@ function email.sendEmail(subject, message_body, settings)
end
local message = buildMessageHeader(os.time(), settings.from_addr, settings.to_addr, settings.cc_addr, subject, message_body)
return ntop.sendMail(from, to, cc, message, smtp_server, settings.username, settings.password)
-- Pass nil username and password when auth is not required
local username = nil
local password = nil
if not isEmptyString(settings.username) then username = settings.username end
if not isEmptyString(settings.password) then password = settings.password end
return ntop.sendMail(from, to, cc, message, smtp_server, username, password)
end
-- ##############################################