I'm trying to send an email behind the socket . I can send an email, with attachment, but I also want to add text to the email and I can not. Code sample:
local smtp = require("socket.smtp")
local mime = require("mime")
local ltn12 = require("ltn12")
rcpt = {
"[email protected]"
}
mesgt = {
headers = {
["content-type"] = 'text/html; charset="ISO-8859-1"',
["content-transfer-encoding"] = 'quoted-printable',
to = "exepmo <"[email protected]">",
["content-type"] = 'image/png; name="image.png"',
["content-disposition"] = 'attachment; filename="image.png"',
["content-description"] = 'a beautiful image',
["content-transfer-encoding"] = "BASE64"
subject = sujet
},
body = "texto texto texto",
[1] = {
body = ltn12.source.chain(
ltn12.source.file(io.open("image.png", "rb")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
}
}
r, e = smtp.send{
from = from,
rcpt = rcpt,
source = smtp.message(mesgt),
port = 21,
server = servidordemail
}
The code works if you send either the text or the attachment. If you want to send the two do not work for me.