- function SendSimpleEmail(title,text) --标题,内容
- local smtp = require("socket.smtp")
- local mime = require("mime")
- local ltn12 = require("ltn12")
- smtp.TIMEOUT = 30;
- local from = "<123456789@qq.com>"; --发件人邮件地址
- local rcpt = {"<xxxxxxxx@qq.com>"}; --收件人邮件地址
- local bodys="";
- local source = smtp.message{ -- 发送内容
- headers = { --表头及标题
- from = from, --来源
- to ="<xxxxxxxx@qq.com>", --收件人邮件地址
- subject = title or "标题" --标题
- },
- body={
- preamble = "",
- [1] = { --邮件内容
- body = mime.eol(0, text or "邮件内容")
- },
- }
- }
- local r, e = smtp.send{
- server="smtp.qq.com",
- -- port=25,
- user="123456789@qq.com",
- password="dfsfrgegreghggj",
- from = from,
- rcpt = rcpt,
- source = source
- }
- return r,e --发送失败时r=nil,e=错误信息 成功时 r==1
- end
复制代码
|