16.07.2023, 10:36
(20.06.2022, 12:21)Hello everyone. I have a specific demand to have a "From" different for the email. I would like to have a from : Maintenance Company BMS and not an email adress. I have tried but I didnt find solution. Wrote: -- make sure these settings are correct
---------------BEGINNING OF USER EDITABLE AREA-------------------
local settings = {
-- "from" field, only e-mail must be specified here
from = 'Maintenance Company BMS',
-- smtp username
user = 'jero*****@gmail.com',
-- smtp password
password = 'wrzss****,
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
secure = 'sslv23',
}
-------------------END OF USER EDITABLE AREA---------------------
local smtp = require('socket.smtp')
local escape = function(v)
return '<' .. tostring(v) .. '>'
end
-- message headers and body
settings.source = smtp.message({
headers = {
to = escape(to),
subject = subject,
},
body = message
})
-- fixup from field
settings.from = escape(settings.from)
settings.rcpt = { escape(to) }
return smtp.send(settings)
end