Guest User

Untitled

a guest
Nov 25th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. local mail = require "resty.mail"
  2.  
  3. local mailer, err = mail.new({
  4. host = "smtp.gmail.com",
  5. port = 587,
  6. starttls = true,
  7. username = "YOUR.USERNAME@gmail.com",
  8. password = "YOUR.PASSWORD",
  9. })
  10. if err then
  11. ngx.log(ngx.ERR, "mail.new error: ", err)
  12. return
  13. end
  14.  
  15. local ok, err = mailer:send({
  16. from = "Master Splinter <splinter@example.com>",
  17. to = { "michelangelo@example.com" },
  18. cc = { "leo@example.com", "Raphael <raph@example.com>", "donatello@example.com" },
  19. subject = "Pizza is here!",
  20. text = "There's pizza in the sewer.",
  21. html = "<h1>There's pizza in the sewer.</h1>",
  22. attachments = {
  23. {
  24. filename = "toppings.txt",
  25. content_type = "text/plain",
  26. content = "1. Cheese\n2. Pepperoni",
  27. },
  28. },
  29. })
  30. if err then
  31. ngx.log(ngx.ERR, "mailer:send error: ", err)
  32. return
  33. end
  34.  
  35. print("mailer:send success: ", ok)
Add Comment
Please, Sign In to add comment