Skip to main content

imap2dict: Receiving and deleting email on an IMAP4 server.

Project description

imap2dict

Description

imap2dict is a Python library for receiving and deleting emails from an IMAP4 server.

Installaction

pip install imap2dict

Usage

from imap2dict import MailClient

host_name = 'mail.example.com'
user_id = 'foo'
password = 'password'

cli = MailClient(host_name, user_id, password)

# Receive email (`search_option` and `timezone` are optional.)
messages = cli.fetch_mail(search_option='UNSEEN', timezone='Asia/Tokyo')
for msg in messages:
    print('UID: {}'.format(msg['uid']))
    print('Subject: {}'.format(msg['subject']))
    print('Body: {}'.format(msg['body']))
    print('From: {}'.format(msg['from']))
    print('To: {}'.format(msg['to']))
    print('Cc: {}'.format(msg['cc']))
    print('Date: {}'.format(msg['date']))
    print('Time: {}'.format(msg['time']))
    print('Format: {}'.format(msg['format']))
    print('Message-ID: {}'.format(msg['msg_id']))
    print('Header: {}'.format(msg['header']))
    for att in msg['attachments']:
        print('File Name: {}'.format(att['file_name']))
        print('File Object: {}'.format(att['file_obj']))

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

imap2dict-0.1.2.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

imap2dict-0.1.2-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

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