lua-users home
lua-l archive

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



On Nov 12, 2008, at 6:53 PM, Jose wrote:

I am new to lua and am looking for the basic function to parse a raw
email message and decode the email content depending on the different
headers.

Ah, yes... a fully compliant MIME parser in pure Lua would be nice... :)

In the meantime, here is a mostly non-compliant one:

http://dev.alt.textdrive.com/browser/HTTP/MIME.lua

Usage example:

local MIME = require( 'MIME' )

local aMIME = MIME( io.open( '3_12_2007.eml', 'rb' ):read( '*all' ) )

print( aMIME.type )

for anIndex, aValue in ipairs( aMIME.content ) do
    print( aValue.type )
end

> multipart/alternative
> text/plain
> text/html

The MIME table has 3 attributes of interest: header, type and content.

Cheers,

--
http://alt.textdrive.com/nanoki/
PA.