我使用下面的代码来实际发送电子邮件。但我没有收到任何错误,也没有收到电子邮件。
-- requires an SMTP server to send emails
local smtp = require("socket.smtp")
local ltn12 = require("ltn12")
local mime = require("mime")
from = "<sender@dataday.com>"
rcpt = {
"<aqs@dataday.com>"
}
-- the multipart message definition
mesgt = {
headers = {
to = "<aqs@dataday.com>",
subject = "Sending attachment over e-mail test"
},
body = {
-- the message content
[1] = {
body = "Sending you a nice file! :D"
},
-- the file attachment
[2] = {
headers = {
["content-type"] = 'attachment; name="test.txt"',
["content-disposition"] = 'attachment; filename="test.txt"',
["content-description"] = 'test binary file',
["content-transfer-encoding"] = "BASE64"
},
body = ltn12.source.chain(
ltn12.source.file( io.open( "/opt/test.txt", "rb")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
}
}
}
-- send the message
r, e = smtp.send{
from = from,
rcpt = rcpt,
source = smtp.message(mesgt),
user = 'sender@dataday.com',
password = 'XXXXXXX',
server = "smtp.1and1.com",
port = 587,
use_ssl = 'try'
}
print(r,e)
上面的代码给出了以下输出。
1 nil
不知道我设置错误的参数。任何帮助将非常感激。
由于