[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua Socket (SMTP)...
- From: Matthew Percival <matthew@...>
- Date: Thu, 01 Sep 2005 16:29:13 +1000
G'Day,
Reviving a dead thread, perhaps, but I seem to have finally found an
answer.
To just briefly relate the setting once more, I was trying to use Lua
Socket to send an email with attachment, but it seemed to just hang.
The same script was able to successfully send the email, though the
attachment was a little messed up on one.
I have been going over this problem, and one point always came back to
me: I could not work out where the source.chain() function ends when the
there is no further source to chain. Eventually, despite plenty of
evidence that it did indeed end (except on this one system), I decided
to assume it did not. The source was a file, returned as chunks by
source.file(), which returns a false (presumably nil) upon reaching EoF,
but source.chain() does not seem to check for this nil. I decided to
add it and see what happens:
while true do
local err
last_in, err = src()
if err then return nil, err end
if not last_in then return nil end
last_out = f(last_in)
if last_out ~= "" then return last_out end
if not last_in then
base.error('filter returned inappropriate ""')
end
end
By adding just the `if not last_in then return nil end' line, my script
now works on the system it did not before. I am able to successfully
send attachments. Almost case closed, but I notice that this system ---
like the one before --- garbles the text a little bit when sending plain
text (eg Lua source). It adds a few extra returns, and the odd extra
characters (most commonly `=0' and `A'). This is only mildly annoying
in most cases, but if I were to try and send a Lua script or something
else sensitive like that, then the attachment would be breaking it.
The problem here likely lies in the filter: I shall begin looking into
it now. I am just happy to be able to say that the worst of it is
finally solved!
-- Matthew