-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy path.preload
More file actions
62 lines (54 loc) · 1.7 KB
/
.preload
File metadata and controls
62 lines (54 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
-- Clone smtp in mako.conf and do a basic sanity check.
local smtpCfg={} -- SMTP config data copied from mako.conf
if not pcall(function()
local conf=require"loadconf"
for k,v in pairs(conf.log.smtp) do smtpCfg[k]=v end -- Clone
if smtpCfg.consec then -- Translate to settings used by socket.mail()
if "starttls" == smtpCfg.consec then
smtpCfg.starttls = true
-- smtpCfg.shark is auto set by socket.mail().
elseif "tls" == smtpCfg.consec then
smtpCfg.shark=ba.sharkclient() -- Must enable TLS
else
trace"Invalid log.smtp.consec settings"
error()
end
end
end)
then -- pcall failed
trace"See the README file for how to configure smtp in mako.conf"
mako.exit()
end
-- The following is done by mako.zip: require"socket.mail"
assert(socket.mail) -- Verify that is was loaded by mako.zip
-- We use the same message as found in this tutorial:
-- https://realtimelogic.com/articles/How-to-Send-Emails-with-Xedge-IDE-A-StepbyStep-Guide
local message=[[
<html>
<body>
<h1>Barracuda App Server Logo</h1>
<img src="cid:the-unique-id" alt="BAS logo">
</body>
</html>
]]
-- Create a Simplified SMTP Client object.
local smtp=socket.mail(smtpCfg)
trace("Sending email.....")
local ok,err=smtp:send{ -- This blocks until message sent
from=smtpCfg.from,
to=smtpCfg.to,
subject="HTML email sent by BAS",
txtbody="The email can only be viewed by an HTML enabled client",
htmlbody=message,
htmlimg={
id="the-unique-id",
name="logo.png",
source=ba.openio"home":open"data/BAS-Logo.png"
}
}
if ok then
trace("Email sent to:",smtpCfg.to)
else
trace("Sending email failed:", err)
end
trace"mako.exit()" mako.exit()