diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index 2930b9a428..9addcbe22f 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -2039,10 +2039,14 @@ local lang = { ["dynamic_interfaces_creation_title"] = "Disaggregation Criterion", ["dynamic_network_interfaces"] = "Dynamic Network Interfaces", ["email_notification"] = "Email Notification", - ["email_notification_address_description"] = "The sender/recipient email address to use.", - ["email_notification_address_title"] = "Email Address", + ["email_notification_recipient_description"] = "The recipient email address.", + ["email_notification_recipient_title"] = "Recipient", + ["email_notification_sender_description"] = "The sender email address.", + ["email_notification_sender_title"] = "Sender", ["email_notification_server_description"] = "The SMTP server to deliver the email. E.g. smtp://example.com:25 .", ["email_notification_server_title"] = "SMTP Server", + ["email_send_error"] = "Email send error. Check out the %{product} log for more details.", + ["email_sent_successfully"] = "Email sent successfully", ["errors"] = "Errors", ["errors_and_warnings"] = "Errors and Warnings", ["ewma_alpha_percent_description"] = "Exponentially Weighted Moving Average (EWMA) alpha coefficient, expressed as a percentage. Used to estimate Autonomous Systems round-trip time.", @@ -2149,6 +2153,7 @@ local lang = { ["secondary_dns_description"] = "A fallback DNS server to use when the global primary DNS server is not available.", ["secondary_dns_title"] = "Global Secondary DNS", ["security_alerts"] = "Security Alerts", + ["send_test_mail"] = "Send Test Email", ["sender_username_description"] = "Set the username of the sender of slack notifications", ["sender_username_title"] = "Notification Sender Username", ["simple_view"] = "Simple View", diff --git a/scripts/lua/admin/prefs.lua b/scripts/lua/admin/prefs.lua index 522a27c121..b4f740912c 100644 --- a/scripts/lua/admin/prefs.lua +++ b/scripts/lua/admin/prefs.lua @@ -21,6 +21,8 @@ sendHTTPContentTypeHeader('text/html') local show_advanced_prefs = false local alerts_disabled = false +local message_info = "" +local message_severity = "alert-warning" if(haveAdminPrivileges()) then if(_POST["flush_alerts_data"] ~= nil) then @@ -29,6 +31,19 @@ if(haveAdminPrivileges()) then elseif(_POST["disable_alerts_generation"] == "1") then require "alert_utils" disableAlertsGeneration() + elseif(_POST["send_test_email"] ~= nil) then + local email_utils = require("email_utils") + + local product = ntop.getInfo(false).product + local success = email_utils.sendEmail(product .. " TEST MAIL", "Email notification is working") + + if success then + message_info = i18n("prefs.email_sent_successfully") + message_severity = "alert-success" + else + message_info = i18n("prefs.email_send_error", {product=product}) + message_severity = "alert-danger" + end end ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc") @@ -38,6 +53,13 @@ if(haveAdminPrivileges()) then prefs = ntop.getPrefs() +if not isEmptyString(message_info) then + print[[]] +end + print [[

Runtime Preferences

]] @@ -347,7 +369,7 @@ function printExternalAlertsReport() if ntop.sendMail then -- only if sendmail is defined, and thus, supported print(''..i18n("prefs.email_notification")..'') - local elementToSwitch = {"row_email_notification_severity_preference", "email_address", "smtp_server"} + local elementToSwitch = {"row_email_notification_severity_preference", "email_sender", "email_recipient", "smtp_server", "alerts_test"} prefsToggleButton({ field = "toggle_email_notification", @@ -372,10 +394,16 @@ function printExternalAlertsReport() "ntopng.prefs.alerts.", "smtp_server", "", "url", showElements and showEmailNotificationPrefs, false, true, {attributes={spellcheck="false"}, required=true}) - prefsInputFieldPrefs(subpage_active.entries["email_notification_address"].title, subpage_active.entries["email_notification_address"].description, - "ntopng.prefs.alerts.", "email_address", + prefsInputFieldPrefs(subpage_active.entries["email_notification_sender"].title, subpage_active.entries["email_notification_sender"].description, + "ntopng.prefs.alerts.", "email_sender", "", "email", showElements and showEmailNotificationPrefs, false, nil, {attributes={spellcheck="false"}, required=true}) - end + + prefsInputFieldPrefs(subpage_active.entries["email_notification_recipient"].title, subpage_active.entries["email_notification_recipient"].description, + "ntopng.prefs.alerts.", "email_recipient", + "", "email", showElements and showEmailNotificationPrefs, false, nil, {attributes={spellcheck="false"}, required=true}) + + print('') + end -- ntop.sendMail print(' '..i18n('prefs.slack_integration')..'') @@ -447,6 +475,18 @@ function printExternalAlertsReport() print('') print [[ ]] + + print[[]] end -- ================================================================================ @@ -1274,7 +1314,9 @@ print[[ dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua") print([[