lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have this script for luasocke-2.0.2 on Linux machine

smtp = require("socket.smtp")
ltn12 = require("ltn12")
mime = require("mime")

headers = {
    Subject = 'Many dots',
    To = "martin@localhost",
}
body_text = [[
Some dots here
...
..
.
..
...
No more dots
]]
body = body_text
message = {
    headers = headers,
    body = body
}
mail = {
    from='martin@localhost',
    rcpt='martin@localhost',
    source = smtp.message(message),
}
assert(smtp.send(mail))

It does send the mail but the mail is truncated ie. it is not stuffed.
If I change line
    body = body_text
with
    bs = ltn12.source.string(body_text)
    filter = mime.normalize()
    body = ltn12.source.chain(bs, filter)
then email is sent as I wanted it to be.

This makes me think that maybe mime.dot() function should be
change a bit in a way to stuff lines that ends with '\n' not only
with '\r\n'. I am aware that RFC require that command to SMTP have
to end with '\r\n' line ends but some MTA servers do accept '\n'
(at least my postfix--and I _belive_ most if not all of them do).
This would make luasocket more cooperative with real world.

Martin