Created
November 25, 2018 15:45
-
-
Save GUI/4ec6e695b400d8128b5708c2acf4e8fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local mail = require "resty.mail" | |
local mailer, err = mail.new({ | |
host = "smtp.gmail.com", | |
port = 587, | |
starttls = true, | |
username = "[email protected]", | |
password = "YOUR.PASSWORD", | |
}) | |
if err then | |
ngx.log(ngx.ERR, "mail.new error: ", err) | |
return | |
end | |
local ok, err = mailer:send({ | |
from = "Master Splinter <[email protected]>", | |
to = { "[email protected]" }, | |
cc = { "[email protected]", "Raphael <[email protected]>", "[email protected]" }, | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment