mime Namespace Reference

This module provides a "defang" function to replace naughty attachments. More...

## Classes

class | _defang
class | HTMLScriptFilter
class | MimeGenerator
| Fix multipart handling in email.Generator. More...
class | MimeMessage
| Enhance email.message.Message. More...
class | SGMLFilter

## Functions

| zipnames (txt)
| Return a list of filenames in a zip file.
| unquote (s)
| _unquotevalue (value)
| message_from_file (fp)
| check_ext (name)
| check_name (msg, savname=None, ckname=check_ext, scan_zip=False)
| check_attachments (msg, check, lev=None)
| check_html (msg, savname=None)
| _list_attach (msg)

## Variables

| BytesIO = StringIO
| as_bytes
str | extlist = ''.join(.split())
list | bad_extensions = ['.' + x for x in extlist.split(',')]
str | virus_msg
| defang = _defang()
| declname = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*')
| declstringlit = re.compile(r'(\'[^\']*\'|"[^"]*")\s*')
| msg = message_from_file(fp)

## Detailed Description

This module provides a "defang" function to replace naughty attachments.

We also provide workarounds for bugs in the email module that comes with python. The "bugs" fixed mostly come up only with malformed messages - but that is what you have when dealing with spam.

## Function Documentation

## check_attachments()

mime.check_attachments | ( |  | msg,
|  |  | check,
|  |  | lev = `None`
| ) |  |

    Scan attachments.
    msg     MimeMessage
    check   function(MimeMessage): int
            Return CONTINUE, REJECT, ACCEPT

References check_attachments().

Referenced by mime._defang.__call__(), and check_attachments().

## unquote()

mime.unquote | ( |  | s | ) |

    Remove quotes from a string.

References unquote().

Referenced by unquote().

## zipnames()

mime.zipnames | ( |  | txt | ) |

Return a list of filenames in a zip file.

Embedded zip files are recursively expanded.

References zipnames().

Referenced by mime.MimeMessage.getnames(), and zipnames().

## Variable Documentation

## virus_msg

str mime.virus_msg

Initial value:
= """This message appeared to contain a virus.
It was originally named '%s', and has been removed.
A copy of your original message was saved as '%s:%s'.
See your administrator.
"""