22.09.2017, 05:24
(This post was last modified: 22.09.2017, 05:25 by phongvucba.)
Please help me !
I use LM3 reactor, I use 2017/6/1 version, but send mail is faulty. I still use that code with version 2016/4/24 still works error.
Does anyone have mail sending errors?
-------------------------
------------------- send an e-mail-----------------------------------------
function mail(to, subject, message)
-- make sure these settings are correct
local settings = {
-- "from" field, only e-mail must be specified here
from = 'abcdxyz@gmail.com',
-- smtp username
user = 'abcdxyz@gmail.com',
-- smtp password
password = 'password',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
secure = 'sslv23',
}
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
-------------------------------
I use LM3 reactor, I use 2017/6/1 version, but send mail is faulty. I still use that code with version 2016/4/24 still works error.
Does anyone have mail sending errors?
-------------------------
------------------- send an e-mail-----------------------------------------
function mail(to, subject, message)
-- make sure these settings are correct
local settings = {
-- "from" field, only e-mail must be specified here
from = 'abcdxyz@gmail.com',
-- smtp username
user = 'abcdxyz@gmail.com',
-- smtp password
password = 'password',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable ssl, required for gmail smtp
secure = 'sslv23',
}
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
-------------------------------