22.09.2023, 12:44
(22.09.2023, 12:40)emmanuel.dassi Wrote:(13.09.2023, 07:49)admin Wrote: If you are not using Gmail then you also need to change the server = '...' parameter in mail() in Common functions. The standard SMTP ports are 465 or 587. For 587 you need to change secure parameter to starttls
When the email is sent successfully then the first logged argument won't be nil.
hello, I still haven't been able to solve my Mail problem, I tried with 2 different mailboxes I don't understand, here is the result of the function that I logged
test de création de fichier csv 22.09.2023 12:08:36
* arg: 1
* nil
* arg: 2
* string: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials n6-20020a05600c294600b0040472ad9a3dsm4302532wmd.14 - gsmtp
I remind you again that my email provider is not Google, here is the script that I took entirely from wiser without modifying anything
-- 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 = '*****@elecit.net',
-- smtp username
user = '*****@elecit.net',
-- smtp password
password = '*******',
-- smtp server
server = 'smtp.1und1.de',
-- 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