mailhog


Namemailhog JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/nklsw/mailhog-python
SummaryA python client for the Mailhog API
upload_time2024-05-05 18:16:52
maintainerNone
docs_urlNone
authornklsw
requires_python<4,>=3.7
licenseMIT
keywords mailhog client wrapper api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mailhog-python

A python client for the [Mailhog](https://github.com/mailhog/MailHog) API


## Installation

Install from PyPI 

```
pip install mailhog
```

## Get Started

```python
from mailhog import Mailhog

mailhog = Mailhog() # Defaults to http://localhost:8025

# Get all messages
mailhog.messages()

# Get all messages with start and limit parameters
mailhog.messages(start=0, limit=10)

# Search for messages
mailhog.search('Text contained in the message')

# Search for messages by recipient
mailhog.search('test@test.com', 'To')

# Search for messages by sender
mailhog.search('test@test.com', 'From')

# Delete all messages
mailhog.delete_all()

# Delete a message
mailhog.delete(messages.items[0])
```

# API
##  mailhog.Mailhog
> Mailhog API client
#### Parameters

* `host` - The host of the Mailhog API, defaults to `localhost`
* `port` - The port of the Mailhog API, defaults to `8025`

### Methods
### `messages(start=0, limit=10)`
> Get all messages

#### Parameters
* `start` - The start index of the messages to return, defaults to `0`
* `limit` - The number of messages to return, defaults to `10`

#### Returns
* `list` - A list of `mailhog.Message` objects

#### Example
```python
from mailhog import Mailhog

mailhog = Mailhog()

messages = mailhog.messages()
```

### `search(query, kind='containing', start=0, limit=10)`
> Search for messages

#### Parameters
* `query` - The query to search for
* `kind` - The kind of search to perform, defaults to `containing`
* `start` - The start index of the messages to return, defaults to `0`
* `limit` - The number of messages to return, defaults to `10`

#### Returns
* `list` - A list of `mailhog.Message` objects

#### Example
```python
from mailhog import Mailhog

mailhog = Mailhog()

messages = mailhog.search('Some Text')
```

### `delete_all()`
> Delete all messages

#### Example
```python
from mailhog import Mailhog

mailhog = Mailhog()

mailhog.delete_all()
```

### `delete()`
> Delete a message

#### Example
```python
from mailhog import Mailhog

mailhog = Mailhog()
messages = mailhog.messages()
mailhog.delete(messages.items[0])
```

# Datatypes
##  mailhog.Messages
> A list of `mailhog.Message` objects
#### Attributes
* `total` - The total number of messages
* `start` - The start index of the messages
* `count` - The total number of received messages
* `items` - A list of `mailhog.Message` objects

##  mailhog.Message
> A message from Mailhog
#### Attributes
* `id` - The ID of the message
* `from_` - A mailhog.Path object containing the sender
* `to` - A List of mailhog.Path objects containing the recipients
* `created` - The date the message was created
* `content` - A mailhog.Content object containing the content of the message
* `raw`: - The raw message
* `mime` - A mailhog.MIME object containing the MIME data of the message

#### Methods
### `get_sender()`
> Get the sender of the message

#### Returns
* `str` - The sender of the message

### `get_recipients()`
> Get the recipients of the message

#### Returns
* `list` - A list of recipients

### `get_subject()`
> Get the subject of the message

#### Returns
* `str` - The subject of the message

##  mailhog.Path
> A path object
#### Attributes
* `relays` - A list of relays
* `mailbox` - The mailbox
* `domain` - The domain
* `params` - The parameters

##  mailhog.Content
> The content of a message
#### Attributes
* `headers` - A Dict of headers of the message
* `body` - The body of the message
* `size` - The size of the message
* `mime` - The MIME type of the message


##  mailhog.MIMEBody
> The body of a MIME message
#### Attributes
* `parts` - A list of mailhog.MIMEContent objects


##  mailhog.MIMEContent
> The content of a MIME message
#### Attributes
* `headers` - A Dict of headers of the message
* `body` - The body of the message
* `size` - The size of the message
* `mime` - The MIME type of the message

___

## About the Package

### WIP

This package is still a work in progress. If you find any bugs or have any suggestions, please open an issue on the [GitHub repository](https://github.com/nklsw/mailhog-python)

### Roadmap

- [x] Mailhog API v2 Messages Endpoint
- [x] Mailhog API v2 Search Endpoint
- [ ] Mailhog API v2 Jim Endpoint
- [x] Mailhog API v1 Delete Messages Endpoint
- [x] Mailhog API v1 Delete Message Endpoint


### Local Development

To install the package locally, run the following commands:

```
git clone
cd mailhog-python

poetry install
```

To run a mailhog instance locally, run the following command:

```
docker-compose up -d
```



To run the tests, run the following command:

```
poetry run pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nklsw/mailhog-python",
    "name": "mailhog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.7",
    "maintainer_email": null,
    "keywords": "mailhog, client, wrapper, api",
    "author": "nklsw",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/41/45/27db1a209cda3512362c95e5d6236b307592ab4668e11371b24c3ae75794/mailhog-0.1.1.tar.gz",
    "platform": null,
    "description": "# mailhog-python\n\nA python client for the [Mailhog](https://github.com/mailhog/MailHog) API\n\n\n## Installation\n\nInstall from PyPI \n\n```\npip install mailhog\n```\n\n## Get Started\n\n```python\nfrom mailhog import Mailhog\n\nmailhog = Mailhog() # Defaults to http://localhost:8025\n\n# Get all messages\nmailhog.messages()\n\n# Get all messages with start and limit parameters\nmailhog.messages(start=0, limit=10)\n\n# Search for messages\nmailhog.search('Text contained in the message')\n\n# Search for messages by recipient\nmailhog.search('test@test.com', 'To')\n\n# Search for messages by sender\nmailhog.search('test@test.com', 'From')\n\n# Delete all messages\nmailhog.delete_all()\n\n# Delete a message\nmailhog.delete(messages.items[0])\n```\n\n# API\n##  mailhog.Mailhog\n> Mailhog API client\n#### Parameters\n\n* `host` - The host of the Mailhog API, defaults to `localhost`\n* `port` - The port of the Mailhog API, defaults to `8025`\n\n### Methods\n### `messages(start=0, limit=10)`\n> Get all messages\n\n#### Parameters\n* `start` - The start index of the messages to return, defaults to `0`\n* `limit` - The number of messages to return, defaults to `10`\n\n#### Returns\n* `list` - A list of `mailhog.Message` objects\n\n#### Example\n```python\nfrom mailhog import Mailhog\n\nmailhog = Mailhog()\n\nmessages = mailhog.messages()\n```\n\n### `search(query, kind='containing', start=0, limit=10)`\n> Search for messages\n\n#### Parameters\n* `query` - The query to search for\n* `kind` - The kind of search to perform, defaults to `containing`\n* `start` - The start index of the messages to return, defaults to `0`\n* `limit` - The number of messages to return, defaults to `10`\n\n#### Returns\n* `list` - A list of `mailhog.Message` objects\n\n#### Example\n```python\nfrom mailhog import Mailhog\n\nmailhog = Mailhog()\n\nmessages = mailhog.search('Some Text')\n```\n\n### `delete_all()`\n> Delete all messages\n\n#### Example\n```python\nfrom mailhog import Mailhog\n\nmailhog = Mailhog()\n\nmailhog.delete_all()\n```\n\n### `delete()`\n> Delete a message\n\n#### Example\n```python\nfrom mailhog import Mailhog\n\nmailhog = Mailhog()\nmessages = mailhog.messages()\nmailhog.delete(messages.items[0])\n```\n\n# Datatypes\n##  mailhog.Messages\n> A list of `mailhog.Message` objects\n#### Attributes\n* `total` - The total number of messages\n* `start` - The start index of the messages\n* `count` - The total number of received messages\n* `items` - A list of `mailhog.Message` objects\n\n##  mailhog.Message\n> A message from Mailhog\n#### Attributes\n* `id` - The ID of the message\n* `from_` - A mailhog.Path object containing the sender\n* `to` - A List of mailhog.Path objects containing the recipients\n* `created` - The date the message was created\n* `content` - A mailhog.Content object containing the content of the message\n* `raw`: - The raw message\n* `mime` - A mailhog.MIME object containing the MIME data of the message\n\n#### Methods\n### `get_sender()`\n> Get the sender of the message\n\n#### Returns\n* `str` - The sender of the message\n\n### `get_recipients()`\n> Get the recipients of the message\n\n#### Returns\n* `list` - A list of recipients\n\n### `get_subject()`\n> Get the subject of the message\n\n#### Returns\n* `str` - The subject of the message\n\n##  mailhog.Path\n> A path object\n#### Attributes\n* `relays` - A list of relays\n* `mailbox` - The mailbox\n* `domain` - The domain\n* `params` - The parameters\n\n##  mailhog.Content\n> The content of a message\n#### Attributes\n* `headers` - A Dict of headers of the message\n* `body` - The body of the message\n* `size` - The size of the message\n* `mime` - The MIME type of the message\n\n\n##  mailhog.MIMEBody\n> The body of a MIME message\n#### Attributes\n* `parts` - A list of mailhog.MIMEContent objects\n\n\n##  mailhog.MIMEContent\n> The content of a MIME message\n#### Attributes\n* `headers` - A Dict of headers of the message\n* `body` - The body of the message\n* `size` - The size of the message\n* `mime` - The MIME type of the message\n\n___\n\n## About the Package\n\n### WIP\n\nThis package is still a work in progress. If you find any bugs or have any suggestions, please open an issue on the [GitHub repository](https://github.com/nklsw/mailhog-python)\n\n### Roadmap\n\n- [x] Mailhog API v2 Messages Endpoint\n- [x] Mailhog API v2 Search Endpoint\n- [ ] Mailhog API v2 Jim Endpoint\n- [x] Mailhog API v1 Delete Messages Endpoint\n- [x] Mailhog API v1 Delete Message Endpoint\n\n\n### Local Development\n\nTo install the package locally, run the following commands:\n\n```\ngit clone\ncd mailhog-python\n\npoetry install\n```\n\nTo run a mailhog instance locally, run the following command:\n\n```\ndocker-compose up -d\n```\n\n\n\nTo run the tests, run the following command:\n\n```\npoetry run pytest\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python client for the Mailhog API",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/nklsw/mailhog-python",
        "Repository": "https://github.com/nklsw/mailhog-python"
    },
    "split_keywords": [
        "mailhog",
        " client",
        " wrapper",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e752b479d173107ad69e553011264542ce0109156b0db6c2656b1ad4b27c2f4",
                "md5": "a70dd69a12fc2d0329ddf95e276d7012",
                "sha256": "e9e798b4cbdab8df87bb23ba9e39bd67c1e9026e1020f05d1e045afda708429f"
            },
            "downloads": -1,
            "filename": "mailhog-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a70dd69a12fc2d0329ddf95e276d7012",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.7",
            "size": 6050,
            "upload_time": "2024-05-05T18:16:50",
            "upload_time_iso_8601": "2024-05-05T18:16:50.940270Z",
            "url": "https://files.pythonhosted.org/packages/8e/75/2b479d173107ad69e553011264542ce0109156b0db6c2656b1ad4b27c2f4/mailhog-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "414527db1a209cda3512362c95e5d6236b307592ab4668e11371b24c3ae75794",
                "md5": "821d9de580f00b5534f52626b90a7807",
                "sha256": "1ab4e9662ee2ae1a73493c208df53d4f2ae3b1c5120648129d2a97a14eea4a93"
            },
            "downloads": -1,
            "filename": "mailhog-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "821d9de580f00b5534f52626b90a7807",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.7",
            "size": 4270,
            "upload_time": "2024-05-05T18:16:52",
            "upload_time_iso_8601": "2024-05-05T18:16:52.433379Z",
            "url": "https://files.pythonhosted.org/packages/41/45/27db1a209cda3512362c95e5d6236b307592ab4668e11371b24c3ae75794/mailhog-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-05 18:16:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nklsw",
    "github_project": "mailhog-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mailhog"
}
        
Elapsed time: 0.49173s