Send an Email from Lua

Verified
Added by iNTERFACEWARE

Use smtp.send() to send an email from your Lua code.

Source Code
function main()
   -- Set up the parameters to be used with sending an email
   local smtpparams={
      header = {To = 'sales@interfaceware.com'; 
                From = '<your email name>'; 
                Date = 'Thu, 23 Aug 2001 21:27:04 -0400';
                Subject = 'Test Subject';},
      username = '<your mail username>',
      password = '<your mail password>',
      server = '<your smtp mail server name>', 
      -- note that the "to" param is actually what is used to send the email, 
      -- the entries in header are only used for display. 
      -- For instance, to do Bcc, add the address in the  'to' parameter but 
      -- omit it from the header.
      to = {'sales@interfaceware.com','admin@interfaceware.com'},
      from = 'Test User ',
      body = 'This is the test body of the email',
      use_ssl = 'try',
      --live = true -- uncomment to run in the editor
   } 
 
  net.smtp.send(smtpparams)
end
Description
Use smtp.send() to send an email from your Lua code.
Usage Details

This code uses smtp.send() to send email from Lua code.

How to use this code:

  • Paste the code into any Lua script component
  • Replace the parameters within the angle brackets <>
    Note: You must a valid username, password and server (smtp mail server)
  • Uncomment the live parameter to test the code in the editor