Skip to main content

A simplified interface to Python's email package.

Project description

maillib

maillib is a wrapper around Python’s email package to provide simple and automatic decoding of messages to unicode and several other conveniences.

Example

>>> import maillib
>>> import datetime
>>>
>>> RAW_MESSAGE = """\
... MIME-version: 1.0
... Date: Sun, 25 Oct 2009 21:12:18 -0500
... Message-id: <c90890f0910251912y40797940ga9f22413411d59dc@mail.gmail.com>
... Subject: =?UTF-8?B?0JLQsNGI0YMg0LzRi9GB0LvRjA==?=
... From: Sender <sender@example.com>
... To: =?UTF-8?B?0JLQu9Cw0LTQuMyB0LzQuNGAINCc0LDRj9C60L7MgdCy0YHQutC40Lk=?=
...  <mayakovsky@example.com>
... Content-type: multipart/alternative; boundary=001636ed670f4e3ad20476cd176b
...
... --001636ed670f4e3ad20476cd176b
... Content-Type: text/plain; charset=UTF-8
... Content-Transfer-Encoding: base64
...
... KtGB0L/QsNGB0LjQsdC+Kgo=
... --001636ed670f4e3ad20476cd176b
... Content-Type: text/html; charset=UTF-8
... Content-Transfer-Encoding: quoted-printable
...
... <span class=3D"Apple-style-span" style=3D"font-family: arial, sans-serif; f=
... ont-size: 13px; border-collapse: collapse; "><b>=D1=81=D0=BF=D0=B0=D1=81=D0=
... =B8=D0=B1=D0=BE</b></span>
...
... --001636ed670f4e3ad20476cd176b--
... """
>>> msg = maillib.Message.from_string(RAW_MESSAGE)
>>> msg.subject
Вашу мысль
>>> msg.sender
(u'Sender', u'sender@example.com')
>>> msg.to
(u'Влади́мир Маяко́вский' u'mayakovsky@example.com')
>>> msg.date
datetime.datetime(2009, 10, 26, 2, 12, 18)
>>> msg.body
спасибо
>>> msg.html
<span class=3D"Apple-style-span" style=3D"font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><b>спасибо</b></span>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maillib-0.1.2.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file maillib-0.1.2.tar.gz.

File metadata

  • Download URL: maillib-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for maillib-0.1.2.tar.gz
Algorithm Hash digest
SHA256 90df11b675dda77d8522d9bdbc7cc3b9e30005d4f17627303c258c56531d54ad
MD5 246487da879a7d6b8ca6ebb5bbd35d9f
BLAKE2b-256 30b62c8860ae3670283962739c70b3e498edae254d46a299199ce829015191dd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page