email: Content-Disposition and linebreaks with long filenames

André Malo auch-ich-m at g-kein-spam.com
Wed Apr 13 05:51:13 EDT 2005


* Martin Körner <me at mkone.net> wrote:

> I am using email module for creating mails with attachment (and then 
> sending via smtplib).
> 
> If the name of the attachment file is longer than about 60 characters 
> the filename is wrapped in the Content-Disposition header:
> 
> Content-Disposition: attachment;
> 	filename="This is a sample file with a very long filename
> 	0123456789.zip"
> 
> 
> This leads to a wrong attachment filename in email clients - the space 
> after "filename" is not shown or the client displays a special character 
> (the linbreak or tab before 0123456789.zip).

Yeah, this is badly applied header folding. You can circumvent it by
encoding the filename parameter according to
<http://ftp.rfc-editor.org/in-notes/rfc2184.txt>

Note that parameter continuation ala filename*1="..."; filename*2="...." is not
really supported by MUAs, but support for filename*="..." seems to be a /bit/ better.

nd



More information about the Python-list mailing list