Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 1.69 KB

README.md

File metadata and controls

69 lines (49 loc) · 1.69 KB

tls-mailer

Presentation

Lua library to send email via SMTP servers with TLS.

It is designed to work within OpenResty as well as outside of it.

Dependencies

Note: the rockspec will install the set of dependencies for use without OpenResty.

With OpenResty

Without OpenResty

Basic usage

local tls_mailer = require "tls-mailer"

local mailer = tls_mailer.new({
  server = "mail.example.com",
  user = "[email protected]",
  password = "V3ryS3cr37",
  cafile = "cacert.pem",
})

local r, e = mailer:send({
  from = "[email protected]",
  to = "[email protected]",
  subject = "my subject",
  text = "my body text",
  attach = { -- facultative array of attachments
    {
      mimetype = "application/stuff",
      fname = "myfile.xxx",
      source = {string = "Hello!"},
      -- or: source = {fname = "myfile.xxx"},
    },
  },
})

To deal with certificates, you must pass a CA extract, which you can get for instance here. With OpenResty this is not necessary and you use lua_ssl_trusted_certificate instead. You can also disable certificate verification (insecure!) with check_cert = false.

Contributors

Copyright

  • Copyright (c) 2013 Moodstocks SAS
  • Copyright (c) 2014-2022 Pierre Chapuis