This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

email?
#2
Hi,

Couple of things to check:

1) Make sure DNS and DG are set correct in the interface settings (otherwise you have no internet access)
2) Enable https://myaccount.google.com/lesssecureapps on your gmail account (otherwise mail from machines is blocked by google)
3) Use these settings in the common functions:
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 = 'yourmail@gmail.com',     -- smtp username     user = 'yourmail@gmail.com',     -- smtp password     password = 'yoursecretpassword',     -- 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   res, err = smtp.send(settings)   return res,err end
4) Send a mail
Code:
subject = 'E-mail test' message = 'Testing e-mail' res, err = mail('yourrecipient@gmail.com', subject, message)
Reply


Messages In This Thread
email? - by Fred - 08.05.2021, 21:44
RE: email? - by Erwin van der Zwart - 09.05.2021, 08:28

Forum Jump: