17.07.2019, 12:49
I'm trying to send an email in lua with slightly modified code from documentation:
Even if I use the original documentation code I get an error:
I did not create tp.lua and unfortunately when I try to open it I get this:
Code:
function mail(to, subject, message)
-- SMTP settings
local settings = {
from = 'mail@example.com',
user = 'mail@example.com',
password = 'password',
server = 'smtp.office365.com',
port = XYZ,
secure = 'starttls',
}
local smtp = require('socket.smtp')
-- message headers and body
settings.source = smtp.message({
headers = {
to = escape(to),
subject = subject,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
-- fixup from field
settings.from = escape(settings.from)
settings.rcpt = { escape(to) }
return smtp.send(settings)
end
Even if I use the original documentation code I get an error:
Code:
Error in /usr/lib/lua/socket/tp.lua at line 0: attempt to index a nil value
I did not create tp.lua and unfortunately when I try to open it I get this:
Quote:The file is not displayed in the editor because it is either binary or uses an unspupported text encoding.