在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
nginx配置 lua_package_path "/usr/local/openresty/lualib/resty/smtp/?.lua;;"; lua_need_request_body on; location ^~ /alarm/mail { resolver 202.106.0.20 valid=3600s; content_by_lua_file /path/to/send_mail.lua; } 其中resolver后为dns服务器ip;
lua代码 local smtp = require "resty.smtp" local mime = require "resty.smtp.mime" local mesgt = { headers= { subject= mime.ew("$subject", nil, { charset= "utf-8" }), ["content-transfer-encoding"]= "BASE64", ["content-type"]= "text/html; charset='utf-8'", }, body= mime.b64("$body") } local ret, err = smtp.send { from= "$from_email", rcpt= { "$to_email" }, user= "$from_email", password= "$password", server= "$smtp_server", port= 25, timeout= 30000, ssl= {enable= false, verify_cert= false}, domain= "$domain", source= smtp.message(mesgt), }
参考: https://github.com/duhoobo/lua-resty-smtp |
请发表评论