Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mail = require "resty.mail"
- local mailer, err = mail.new({
- host = "smtp.gmail.com",
- port = 587,
- starttls = true,
- username = "YOUR.USERNAME@gmail.com",
- password = "YOUR.PASSWORD",
- })
- if err then
- ngx.log(ngx.ERR, "mail.new error: ", err)
- return
- end
- local ok, err = mailer:send({
- from = "Master Splinter <splinter@example.com>",
- to = { "michelangelo@example.com" },
- cc = { "leo@example.com", "Raphael <raph@example.com>", "donatello@example.com" },
- subject = "Pizza is here!",
- text = "There's pizza in the sewer.",
- html = "<h1>There's pizza in the sewer.</h1>",
- attachments = {
- {
- filename = "toppings.txt",
- content_type = "text/plain",
- content = "1. Cheese\n2. Pepperoni",
- },
- },
- })
- if err then
- ngx.log(ngx.ERR, "mailer:send error: ", err)
- return
- end
- print("mailer:send success: ", ok)
Add Comment
Please, Sign In to add comment