Issue
Unsure what options are available in the Lua smtp.send() function.
Product Line
SmartStruxure Lite
Environment
SmartStruxure Lite MPM
Cause
The Lua smtp.send() function is not fully documented.
Resolution
The syntax of the smtp.send() function is:
smtp.send
{ from = string, rcpt = string or string-table, source = LTN12 source, [server = string,] [user = string,] [password = string,] [port = number,] [domain = string] }
From above you can see that the "from", "rcpt" and "source" fields are required. Whilst "server", "user", "password", "port" and "domain" fields are optional.
Example Lua code is:
--==============================================================================
-- SSL email notification script example
--==============================================================================
-- Define the input you want to monitor below
var("temperature", "ME.AI1") -- Room Temperature
limit = 78 -- define the threshold
now = scl.sysclock()
if (temperature > limit) then -- When temperature is above threshold
if (sent == nil) -- Check if e-mail was already sent
and ((last == nil) or (now - last > 15 * 60)) then -- Maximum every 15 minutes
sent = true -- Only send e-mail once
last = now -- Keep track of last time
result, reason = smtp.send {
user = "alerts@server.com", -- Enter your existing SMTP username
password = "test1234", -- Enter your existing SMTP password
from = "alerts@company.com", -- Enter your existing Source address
rcpt = {
"user1@company.com", -- First recipient
"user2@company.com", -- Second recipient
"user3@company.com" -- Third recipient
},
source = smtp.message( {
headers = {
from = "alerts@company.com", -- Displayed source address
to = "technicians@company.com", -- Displayed recipients
subject = "Temperature Alert" -- E-mail title
},
body = "Current temperature is: " .. temperature .. " (above " .. limit .. ")" .. " [" .. os.date() .. "]"}),
server = "server.com" – enter your SMTP server
}
if result ~= 1 then
print(os.date(), "E-mail was NOT sent:", reason)
else
print(os.date(), "E-mail was successfully sent.")
end
end
else
sent = nil -- Re-enable alerting on condition
end
--[[
Disclaimer: We hope that this script example and associated information (the
"information") is valuable to you. Your use of this information, however, is
at your sole risk. All information is provided "as -is", without any warranty,
whether express or implied, of its accuracy, completeness, fitness for a
particular purpose, title or non-infringement, and none of the third-party
products or information mentioned in the work are authored, recommended,
supported or guaranteed by Schneider Electric.. Further, Schneider Electric. shall
not be liable for any damages you may sustain by using/installing/modifying
this information, whether direct, indirect, special, incidental or
consequential, even if it has been advised of the possibility of such damages.
--]]