(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
if type(to) ~= 'table' then
to = { to }
end
for index, email in ipairs(to) do
to[ index ] = '<' .. tostring(email) .. '>'
end
-- fixup from field
local from = '<' .. tostring(settings.from) .. '>'
-- message headers and body
settings.source = smtp.message({
headers = {
to = table.concat(to, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:
Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:
-- make sure mail settings are set in user function library before using this function
Code:
subject = 'Der er kommet post'
Code:
message = 'Med Venlig Hilsen Kastaniely'
Code:
res, err = mail('TSA@InoDes.dk', subject, message)
Code:
log(res, err)
Code:
--mail('TSA@InoDes.dk', subject, message)
Code:
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
(20.08.2020, 10:19)Tue Wrote:(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
if type(to) ~= 'table' then
to = { to }
end
for index, email in ipairs(to) do
to[ index ] = '<' .. tostring(email) .. '>'
end
-- fixup from field
local from = '<' .. tostring(settings.from) .. '>'
-- message headers and body
settings.source = smtp.message({
headers = {
to = table.concat(to, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:-- make sure mail settings are set in user function library before using this function
subject = 'Der er kommet post'
message = 'Med Venlig Hilsen Kastaniely'
res, err = mail('TSA@InoDes.dk', subject, message)
log(res, err)
--mail('TSA@InoDes.dk', subject, message)
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
(20.08.2020, 10:19)Tue Wrote:Is there anything else in system, I can check (It has newer been able to send Email, have tryeid many times to get it to work). Any port in my Network (IP) that has to be speciel or anything else on server that can block it?(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
if type(to) ~= 'table' then
to = { to }
end
for index, email in ipairs(to) do
to[ index ] = '<' .. tostring(email) .. '>'
end
-- fixup from field
local from = '<' .. tostring(settings.from) .. '>'
-- message headers and body
settings.source = smtp.message({
headers = {
to = table.concat(to, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:-- make sure mail settings are set in user function library before using this function
Code:subject = 'Der er kommet post'
Code:message = 'Med Venlig Hilsen Kastaniely'
Code:res, err = mail('TSA@InoDes.dk', subject, message)
Code:log(res, err)
Code:--mail('TSA@InoDes.dk', subject, message)
Code:POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)
(20.08.2020, 10:19)Tue Wrote:(20.08.2020, 10:04)Daniel. Wrote: Replace the whole email function as it sound as you were upgrading an old device and then old libraries are preserved.
Code:-- 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 = 'example@gmail.com',
-- smtp username
user = 'example@gmail.com',
-- smtp password
password = 'mypassword',
-- smtp server
server = 'smtp.gmail.com',
-- smtp server port
port = 465,
-- enable tls, required for gmail smtp
secure = 'tlsv1_2',
}
local smtp = require('socket.smtp')
if type(to) ~= 'table' then
to = { to }
end
for index, email in ipairs(to) do
to[ index ] = '<' .. tostring(email) .. '>'
end
-- fixup from field
local from = '<' .. tostring(settings.from) .. '>'
-- message headers and body
settings.source = smtp.message({
headers = {
to = table.concat(to, ', '),
subject = subject,
['From'] = from,
['Content-type'] = 'text/html; charset=utf-8',
},
body = message
})
settings.from = from
settings.rcpt = to
return smtp.send(settings)
end
Copy pasted all ofyours in under common functions (And replaced Email and code with my own)
But still get no Email, and this error:
Code:Postkasse post ind 20.08.2020 12:01:21
* arg: 1
* nil
* arg: 2
* string: Try again
Using this code in triggered script
Code:-- make sure mail settings are set in user function library before using this function
subject = 'Der er kommet post'
message = 'Med Venlig Hilsen Kastaniely'
res, err = mail('TSA@InoDes.dk', subject, message)
log(res, err)
--mail('TSA@InoDes.dk', subject, message)
POSTevnt(1) -- Kald funktion med event 1 (Post er kommet)