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 sending
#9
(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
Reply


Messages In This Thread
email sending - by Fistel - 05.05.2025, 08:02
RE: email sending - by Daniel - 05.05.2025, 08:48
RE: email sending - by Fistel - 06.05.2025, 16:51
RE: email sending - by Fistel - 07.05.2025, 16:37
RE: email sending - by Erwin van der Zwart - 05.05.2025, 08:55
RE: email sending - by admin - 07.05.2025, 13:32
RE: email sending - by JuLopez - 27.11.2025, 11:25
RE: email sending - by admin - 27.11.2025, 11:32
RE: email sending - by JuLopez - 27.11.2025, 11:52
RE: email sending - by admin - 27.11.2025, 11:55
RE: email sending - by JuLopez - 27.11.2025, 12:08
RE: email sending - by admin - 27.11.2025, 12:18
RE: email sending - by JuLopez - 27.11.2025, 12:20

Forum Jump: