Я использую приведенный ниже код, чтобы отправить электронное письмо. Но я не получаю ни ошибок, ни электронной почты.
-- requires an SMTP server to send emails
local smtp = require("socket.smtp")
local ltn12 = require("ltn12")
local mime = require("mime")
from = "<[email protected]>"
rcpt = {
"<[email protected]>"
}
-- the multipart message definition
mesgt = {
headers = {
to = "<[email protected]>",
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 = '[email protected]',
password = 'XXXXXXX',
server = "smtp.1and1.com",
port = 587,
use_ssl = 'try'
}
print(r,e)
Приведенный выше код дает мне результат ниже.
1 nil
Не знаю, какой параметр я устанавливаю неправильно. Любая помощь приветствуется.
Спасибо
Да, я проверил свой спам-ящик. Там тоже ничего не было. Но электронную почту без вложений не проверял. У меня есть другой скрипт python, который успешно отправляет почту с вложением. Спасибо, что полагаетесь. Я попробую с sendmail.

Не могли бы вы проверить свой ящик для спама. А без вложения работает? Автоматическая почта, как правило, отправляется туда. В любом случае я рекомендую отправлять почту с помощью sendmail (как API, так и с каким-нибудь nullmailer). Итак, у вас есть очереди и журналы.