lua-users home
lua-l archive

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


Hi

The case sensitivity seems only to apply to the attachment part of a
multipart email. Extracting a little code demonstrates the point:

	local multipart = {}
	-- email body
	table.insert ( multipart,
		{ headers = {["content-type"] = content }, -- ok case independent
	        body = mime.eol(0, message) } )
	....
	-- build attachment header
	local type = ""..file_mime[ext].."; name=\""..filename.."\""
	local disposition = "attachment; filename=\""..filename.."\""
	local encoding = file_encode[ext]
	local head = {
	   ["content-type"] = type, -- this works, but NOT if case changed
	   ["content-disposition"] = disposition,
	   ["content-transfer-encoding"] = encoding }
	....
	table.insert( multipart, { headers = head, body = attachment } )
	....
	mesgt = {
	  headers = {
	     to = recipients,
	     subject = title },
	  body = multipart }
	....
	res, mess = smtp.send {
	   from = my_address,
	   rcpt = rcpt,
	   source = smtp.message(mesgt),
	   server = mailserv,
	   port = mailport }

The result can be seen in a raw email view. I have not yet graduated
from Lua 101, so the mistake is probably mine!. Can sent entire module
if interested.

Regards
Graham

On 11/03/2007, at 8:03 AM, Diego Nehab wrote:

Yes, the smtp.lua module is case sensitive on *content-type:* which
if not assigned, is loaded with an inappropriate default. *Content_Type:*
is treated as a separate user added header. Problem was easily
solved, thank you.

It should not be case sensitive. Are you using smtp.message
to create a source for your message? Can you send me a tiny
example? The function "adjust_headers" should convert
everything to lowercase. Maybe I screwed up somewhere...

I followed this through a bit but the flow path through smtp.lua
was not that obvious to me for multipart mails.


Problem 2. was less obvious. We supplied a value to *from*
in smtp.send call as per manual example. However it is also required
as a separately defined header (which is in the multipart example on
closer inspection). No doubt there are good reasons for this.

The "from" in smtp.send is the argument to the "SMTP FROM" command.
This has nothing to do with the header "From:". The former
tells the server who should receive the message. The latter
is just for display purposes. I can't add the addresses from
the command to the header because you might want to do a BCC
instead. All this is explained in the documentation.

Regards,
Diego.