27.11.2025, 11:52
(27.11.2025, 11:32)admin Wrote: Use this to get the result/error in Logs tab.
Code:res, err = mail('ju*********@gmail.com', subject, message)
log(res, err)
Don't randomly change the mail() function. You only need to change the settings table, everything else should be kept as is. In your case the 'From' header is invalid because the assigned variable is not defined.
Thanks for the point. I forgot to include the log, but when I run the script again, I get no response from either the log or the error log, even though I added the log before running it. I'm also not receiving the email. I've also removed the "From" from the message body, so it now looks like this (in Comm Func) :
Code:
function mail(to, subject, message)
local settings = {
-- "from" field, only e-mail must be specified here
from ='al************@gmail.com',
-- smtp username
user = 'LM**********',
-- smtp password
password = 's************',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
-- secure = 'tlsv1_2',
secure = 'sslv23'
}
local smtp = require('socket.smtp')
local escape = function(v)
return '<' .. tostring .. '>'
end
-- message headers and body
settings.source = smtp.message({
headers = {
to = escape(to),
subject = subject,
},
body = message
})
settings.from = escape(settings.from)
settings.rcpt = { escape(to)}
return smtp.send(settings)
end