imap-mailbox


Nameimap-mailbox JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://medecau.github.io/imap_mailbox/
Summarymailbox over IMAP
upload_time2023-01-26 07:34:03
maintainer
docs_urlNone
authorPedro Rodrigues
requires_python>=3.8,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *Please note that `imap_mailbox` is still under active development and will be subject to significant changes.*

```python
import imap_mailbox

# connect to the IMAP server
with imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:
    
    # search messages from vip@example.com
    uids = mailbox.search('FROM', 'vip@example.com')
    
    # move the messages to the 'VIP' folder
    mailbox.move(uids, 'VIP')
```

This module provides a subclass of `mailbox.Mailbox` that allows you to interact with an IMAP server. It is designed to be a drop-in replacement for the standard library `mailbox` module.

# Installation

Install the latest stable version from PyPI:

```bash
pip install imap-mailbox
```

Install the latest version from GitHub:

```bash
pip install https://github.com/medecau/imap_mailbox/archive/refs/heads/main.zip
```

# Examples

## Iterate over messages in a folder

```python
import imap_mailbox

# connect to the IMAP server
with imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:
    
    # select the INBOX folder
    mailbox.select('INBOX')
    
    # iterate over messages in the folder
    for message in mailbox:
        print(f"From: {message['From']}")
        print(f"Subject: {message['Subject']}")
```

## Connect to a Proton Mail account

```python
import imap_mailbox

# connect to the local IMAP bridge
with imap_mailbox.IMAPMailbox(
    '127.0.0.1', 'username', 'password'
    port=1143, security='STARTTLS'
    ) as mailbox:
    
    # search messages from your friend
    uids = mailbox.search('FROM', 'handler@proton.me')

    # erase the evidence
    mailbox.delete(uids)
    
```
_this is a joke; don't use proton for crimes – stay safe_

## Delete messages from a noisy sender

```python
import imap_mailbox

with imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:
    
    # search messages from
    uids = mailbox.search('FROM', 'spammer@example.com')

    # delete the messages
    mailbox.delete(uids)
```

## Delete GitHub messages older than two years

```python
import imap_mailbox

with imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:
    
    # search messages older than two years from github.com
    uids = mailbox.search('NOT PAST2YEARS FROM github.com')
    
    # delete the messages
    mailbox.delete(uids)
```

# Contribution

Help improve imap_mailbox by reporting any issues or suggestions on our issue tracker at [github.com/medecau/imap_mailbox/issues](https://github.com/medecau/imap_mailbox/issues).

Get involved with the development, check out the source code at [github.com/medecau/imap_mailbox](https://github.com/medecau/imap_mailbox).

            

Raw data

            {
    "_id": null,
    "home_page": "https://medecau.github.io/imap_mailbox/",
    "name": "imap-mailbox",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Pedro Rodrigues",
    "author_email": "medecau@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/23/7c/a63e124e41d5b4d73dd0b59013a381f649b90c35a8e14c87f4d2a84fa295/imap_mailbox-0.2.0.tar.gz",
    "platform": null,
    "description": "*Please note that `imap_mailbox` is still under active development and will be subject to significant changes.*\n\n```python\nimport imap_mailbox\n\n# connect to the IMAP server\nwith imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:\n    \n    # search messages from vip@example.com\n    uids = mailbox.search('FROM', 'vip@example.com')\n    \n    # move the messages to the 'VIP' folder\n    mailbox.move(uids, 'VIP')\n```\n\nThis module provides a subclass of `mailbox.Mailbox` that allows you to interact with an IMAP server. It is designed to be a drop-in replacement for the standard library `mailbox` module.\n\n# Installation\n\nInstall the latest stable version from PyPI:\n\n```bash\npip install imap-mailbox\n```\n\nInstall the latest version from GitHub:\n\n```bash\npip install https://github.com/medecau/imap_mailbox/archive/refs/heads/main.zip\n```\n\n# Examples\n\n## Iterate over messages in a folder\n\n```python\nimport imap_mailbox\n\n# connect to the IMAP server\nwith imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:\n    \n    # select the INBOX folder\n    mailbox.select('INBOX')\n    \n    # iterate over messages in the folder\n    for message in mailbox:\n        print(f\"From: {message['From']}\")\n        print(f\"Subject: {message['Subject']}\")\n```\n\n## Connect to a Proton Mail account\n\n```python\nimport imap_mailbox\n\n# connect to the local IMAP bridge\nwith imap_mailbox.IMAPMailbox(\n    '127.0.0.1', 'username', 'password'\n    port=1143, security='STARTTLS'\n    ) as mailbox:\n    \n    # search messages from your friend\n    uids = mailbox.search('FROM', 'handler@proton.me')\n\n    # erase the evidence\n    mailbox.delete(uids)\n    \n```\n_this is a joke; don't use proton for crimes \u2013 stay safe_\n\n## Delete messages from a noisy sender\n\n```python\nimport imap_mailbox\n\nwith imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:\n    \n    # search messages from\n    uids = mailbox.search('FROM', 'spammer@example.com')\n\n    # delete the messages\n    mailbox.delete(uids)\n```\n\n## Delete GitHub messages older than two years\n\n```python\nimport imap_mailbox\n\nwith imap_mailbox.IMAPMailbox('imap.example.com', 'username', 'password') as mailbox:\n    \n    # search messages older than two years from github.com\n    uids = mailbox.search('NOT PAST2YEARS FROM github.com')\n    \n    # delete the messages\n    mailbox.delete(uids)\n```\n\n# Contribution\n\nHelp improve imap_mailbox by reporting any issues or suggestions on our issue tracker at [github.com/medecau/imap_mailbox/issues](https://github.com/medecau/imap_mailbox/issues).\n\nGet involved with the development, check out the source code at [github.com/medecau/imap_mailbox](https://github.com/medecau/imap_mailbox).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "mailbox over IMAP",
    "version": "0.2.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2466818183252898555b5600dc040c1532e0a06cfee397a9054d406ae65eb273",
                "md5": "805a800a55f118bd8b7f3e2b243484b6",
                "sha256": "61b7838d039968c943e9a0c61a4f90969de0e344b5ae5743f7ff203dfd55e7c8"
            },
            "downloads": -1,
            "filename": "imap_mailbox-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "805a800a55f118bd8b7f3e2b243484b6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5774,
            "upload_time": "2023-01-26T07:34:01",
            "upload_time_iso_8601": "2023-01-26T07:34:01.913249Z",
            "url": "https://files.pythonhosted.org/packages/24/66/818183252898555b5600dc040c1532e0a06cfee397a9054d406ae65eb273/imap_mailbox-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "237ca63e124e41d5b4d73dd0b59013a381f649b90c35a8e14c87f4d2a84fa295",
                "md5": "deb588010bce1e78ff56515247cf77db",
                "sha256": "fdba27f4384861f4c6cdef5bafd75666a1138003c1f00b1228a9f55dfa3eae80"
            },
            "downloads": -1,
            "filename": "imap_mailbox-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "deb588010bce1e78ff56515247cf77db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 6007,
            "upload_time": "2023-01-26T07:34:03",
            "upload_time_iso_8601": "2023-01-26T07:34:03.180008Z",
            "url": "https://files.pythonhosted.org/packages/23/7c/a63e124e41d5b4d73dd0b59013a381f649b90c35a8e14c87f4d2a84fa295/imap_mailbox-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-26 07:34:03",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "imap-mailbox"
}
        
Elapsed time: 0.06112s