1secMail


Name1secMail JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/qvco/1secMail-Python
Summary📧 Simple and intuitive, yet full featured API wrapper for www.1secmail.com, supporting both synchronous and asynchronous operations.
upload_time2023-12-20 06:22:25
maintainerqvco
docs_urlNone
authorqvco
requires_python
licenseMIT
keywords 1secmail onesecmail tempmail disposable temporary email api wrapper library async asynchronous
VCS
bugtrack_url
requirements httpx
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <br>
  <img src="https://github.com/qvco/1secMail-Python/assets/77382767/fde69c1a-b95f-4d78-af1a-2dca315204bc" alt="1secMail" width="700">
<!--   <br>
  1secMail for Python
  <br> -->
</p>

<h4 align="center">An API wrapper for <a href="https://www.1secmail.com/" target="_blank">www.1secmail.com</a> written in Python.</h4>

  <p align="center">
    <img src="https://img.shields.io/github/release/qvco/1secMail-Python">
    <img src="https://img.shields.io/badge/python-3.8-blue.svg">
    <img src="https://img.shields.io/badge/License-MIT-blue.svg">
  </p>

### About

This is an easy to use yet full-featured Python API wrapper for www.1secmail.com ↗ using the official 1secMail API. It allows you to easily create temporary email addresses for testing, verification, or other purposes where you need a disposable email address.  
> Asynchronous operations are also supported!:thumbsup:

### Install

To install the package, you'll need Python 3.8 or above installed on your computer. From your command line:

```bash
pip install 1secMail
```

<br>

> **Note**
> If you're willing to install the development version, do the following:

```bash
git clone https://github.com/qvco/1secMail-Python.git

cd 1secMail-Python

pip install -r requirements.txt

pip install -e .
```

## Usage

### Generating Email Addresses

To generate a list of random email addresses, use the `random_email()` method:

```python
import secmail

client = secmail.Client()

client.random_email(amount=3)
>>> ['c3fho3cry1@1secmail.net', '5qcd3d36zr@1secmail.org', 'b6fgeothtg@1secmail.net']
```

You can also generate a custom email address by specifying the username and domain:

> **Note**
> Specifying a domain is optional!

```python
client.custom_email(username="bobby-bob", domain="kzccv.com")
>>> 'bobby-bob@kzccv.com'
```

### Receiving Messages

To wait until a new message is received, use the `await_new_message()` method:

```python
message = client.await_new_message("bobby-bob@kzccv.com")
```

To check all messages received on a particular email address, use the `get_inbox()` method and pass the email address:

```python
inbox = client.get_inbox("bobby-bob@kzccv.com")
for message in inbox:
    print(message.id)
    print(message.from_address)
    print(message.subject)
    print(message.date)
```

You can also fetch a single message using the `get_message()` method and passing the email address and message ID:

```python
message = client.get_message(address="bobby-bob@kzccv.com", message_id=235200687)
print(message.id)
print(message.subject)
print(message.body)
print(message.text_body)
print(message.html_body)
print(message.attachments)
print(message.date)
```

### Downloading an attachment

You can download an attachment from a message in the inbox of a specified email address using the download_attachment method like this:

```python
client.download_attachment(address, message_id, attachment_filename)
>>> 'Path: (C:\Users\user\path/config/rocket.png), Size: 49071B'
```

## Asynchronous Client

### Generating Email Addresses

To generate a list of random email addresses, use the `random_email()` method:

```python
import asyncio
import secmail

async def main():
    client = secmail.AsyncClient()
    email_addresses = await client.random_email(amount=3)
    print(email_addresses)

asyncio.run(main())
>>> ['c3fho3cry1@1secmail.net', '5qcd3d36zr@1secmail.org', 'b6fgeothtg@1secmail.net']
```

You can also generate a custom email address by specifying the username and domain:

> **Note**
> Specifying a domain is optional!

```python
await client.custom_email(username="bobby-bob", domain="kzccv.com")
>>> 'bobby-bob@kzccv.com'
```

### Receiving Messages

To wait until a new message is received, use the `await_new_message()` method:

```python
import asyncio
import secmail

async def main():
    client = secmail.AsyncClient()
    message = await client.await_new_message("bobby-bob@kzccv.com")
    print(f"{message.from_address}: {message.subject}")

asyncio.run(main())
```

To check all messages received on a particular email address, use the `get_inbox()` method and pass the email address:

```python
import asyncio
import secmail

async def main():
    client = secmail.AsyncClient()
    inbox = await client.get_inbox("bobby-bob@kzccv.com")
    print(f"You have {len(inbox)} messages in your inbox.")

    for message in inbox:
        print(message.id)
        print(message.from_address)
        print(message.subject)
        print(message.date)

asyncio.run(main())
```

You can also fetch a single message using the `get_message()` method and passing the email address and message ID:

```python
import asyncio
import secmail

async def main():
    client = secmail.AsyncClient()
    address = "bobby-bob@kzccv.com"
    inbox = await client.get_inbox(address)
    message_id = inbox[0].id
    message = await client.get_message(address, message_id)

    print(message.id)
    print(message.subject)
    print(message.body)
    print(message.text_body)
    print(message.html_body)
    print(message.attachments)
    print(message.date)

asyncio.run(main())
```

### Downloading an attachment

You can download an attachment from a message in the inbox of a specified email address using the download_attachment method like this:

```python
import asyncio
import secmail

async def main():
    client = secmail.AsyncClient()
    address = "bobby-bob@kzccv.com"
    inbox = await client.get_inbox(address)
    message_id = inbox[0].id
    message = await client.get_message(address, message_id)
    attachment_filename = message.attachments[0].filename
    await client.download_attachment(address, message_id, attachment_filename)

asyncio.run(main())

>>> 'Path: (C:\Users\user\path/config/rocket.png), Size: 49071B'
```

## Licnese

This software is licensed under the [MIT](https://github.com/qvco/1secMail-Python/blob/master/LICENSE) © [Qvco](https://github.com/qvco).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/qvco/1secMail-Python",
    "name": "1secMail",
    "maintainer": "qvco",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "nikola.desuga@gmail.com",
    "keywords": "1secmail,onesecmail,tempmail,disposable,temporary,email,api,wrapper,library,async,asynchronous",
    "author": "qvco",
    "author_email": "nikola.desuga@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d3/cb/9908c2735deef9b2ddc94c64c2709a9724495da4884fe4e1954196310266/1secMail-1.2.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\r\n  <br>\r\n  <img src=\"https://github.com/qvco/1secMail-Python/assets/77382767/fde69c1a-b95f-4d78-af1a-2dca315204bc\" alt=\"1secMail\" width=\"700\">\r\n<!--   <br>\r\n  1secMail for Python\r\n  <br> -->\r\n</p>\r\n\r\n<h4 align=\"center\">An API wrapper for <a href=\"https://www.1secmail.com/\" target=\"_blank\">www.1secmail.com</a> written in Python.</h4>\r\n\r\n  <p align=\"center\">\r\n    <img src=\"https://img.shields.io/github/release/qvco/1secMail-Python\">\r\n    <img src=\"https://img.shields.io/badge/python-3.8-blue.svg\">\r\n    <img src=\"https://img.shields.io/badge/License-MIT-blue.svg\">\r\n  </p>\r\n\r\n### About\r\n\r\nThis is an easy to use yet full-featured Python API wrapper for www.1secmail.com \u2197 using the official 1secMail API. It allows you to easily create temporary email addresses for testing, verification, or other purposes where you need a disposable email address.  \r\n> Asynchronous operations are also supported!:thumbsup:\r\n\r\n### Install\r\n\r\nTo install the package, you'll need Python 3.8 or above installed on your computer. From your command line:\r\n\r\n```bash\r\npip install 1secMail\r\n```\r\n\r\n<br>\r\n\r\n> **Note**\r\n> If you're willing to install the development version, do the following:\r\n\r\n```bash\r\ngit clone https://github.com/qvco/1secMail-Python.git\r\n\r\ncd 1secMail-Python\r\n\r\npip install -r requirements.txt\r\n\r\npip install -e .\r\n```\r\n\r\n## Usage\r\n\r\n### Generating Email Addresses\r\n\r\nTo generate a list of random email addresses, use the `random_email()` method:\r\n\r\n```python\r\nimport secmail\r\n\r\nclient = secmail.Client()\r\n\r\nclient.random_email(amount=3)\r\n>>> ['c3fho3cry1@1secmail.net', '5qcd3d36zr@1secmail.org', 'b6fgeothtg@1secmail.net']\r\n```\r\n\r\nYou can also generate a custom email address by specifying the username and domain:\r\n\r\n> **Note**\r\n> Specifying a domain is optional!\r\n\r\n```python\r\nclient.custom_email(username=\"bobby-bob\", domain=\"kzccv.com\")\r\n>>> 'bobby-bob@kzccv.com'\r\n```\r\n\r\n### Receiving Messages\r\n\r\nTo wait until a new message is received, use the `await_new_message()` method:\r\n\r\n```python\r\nmessage = client.await_new_message(\"bobby-bob@kzccv.com\")\r\n```\r\n\r\nTo check all messages received on a particular email address, use the `get_inbox()` method and pass the email address:\r\n\r\n```python\r\ninbox = client.get_inbox(\"bobby-bob@kzccv.com\")\r\nfor message in inbox:\r\n    print(message.id)\r\n    print(message.from_address)\r\n    print(message.subject)\r\n    print(message.date)\r\n```\r\n\r\nYou can also fetch a single message using the `get_message()` method and passing the email address and message ID:\r\n\r\n```python\r\nmessage = client.get_message(address=\"bobby-bob@kzccv.com\", message_id=235200687)\r\nprint(message.id)\r\nprint(message.subject)\r\nprint(message.body)\r\nprint(message.text_body)\r\nprint(message.html_body)\r\nprint(message.attachments)\r\nprint(message.date)\r\n```\r\n\r\n### Downloading an attachment\r\n\r\nYou can download an attachment from a message in the inbox of a specified email address using the download_attachment method like this:\r\n\r\n```python\r\nclient.download_attachment(address, message_id, attachment_filename)\r\n>>> 'Path: (C:\\Users\\user\\path/config/rocket.png), Size: 49071B'\r\n```\r\n\r\n## Asynchronous Client\r\n\r\n### Generating Email Addresses\r\n\r\nTo generate a list of random email addresses, use the `random_email()` method:\r\n\r\n```python\r\nimport asyncio\r\nimport secmail\r\n\r\nasync def main():\r\n    client = secmail.AsyncClient()\r\n    email_addresses = await client.random_email(amount=3)\r\n    print(email_addresses)\r\n\r\nasyncio.run(main())\r\n>>> ['c3fho3cry1@1secmail.net', '5qcd3d36zr@1secmail.org', 'b6fgeothtg@1secmail.net']\r\n```\r\n\r\nYou can also generate a custom email address by specifying the username and domain:\r\n\r\n> **Note**\r\n> Specifying a domain is optional!\r\n\r\n```python\r\nawait client.custom_email(username=\"bobby-bob\", domain=\"kzccv.com\")\r\n>>> 'bobby-bob@kzccv.com'\r\n```\r\n\r\n### Receiving Messages\r\n\r\nTo wait until a new message is received, use the `await_new_message()` method:\r\n\r\n```python\r\nimport asyncio\r\nimport secmail\r\n\r\nasync def main():\r\n    client = secmail.AsyncClient()\r\n    message = await client.await_new_message(\"bobby-bob@kzccv.com\")\r\n    print(f\"{message.from_address}: {message.subject}\")\r\n\r\nasyncio.run(main())\r\n```\r\n\r\nTo check all messages received on a particular email address, use the `get_inbox()` method and pass the email address:\r\n\r\n```python\r\nimport asyncio\r\nimport secmail\r\n\r\nasync def main():\r\n    client = secmail.AsyncClient()\r\n    inbox = await client.get_inbox(\"bobby-bob@kzccv.com\")\r\n    print(f\"You have {len(inbox)} messages in your inbox.\")\r\n\r\n    for message in inbox:\r\n        print(message.id)\r\n        print(message.from_address)\r\n        print(message.subject)\r\n        print(message.date)\r\n\r\nasyncio.run(main())\r\n```\r\n\r\nYou can also fetch a single message using the `get_message()` method and passing the email address and message ID:\r\n\r\n```python\r\nimport asyncio\r\nimport secmail\r\n\r\nasync def main():\r\n    client = secmail.AsyncClient()\r\n    address = \"bobby-bob@kzccv.com\"\r\n    inbox = await client.get_inbox(address)\r\n    message_id = inbox[0].id\r\n    message = await client.get_message(address, message_id)\r\n\r\n    print(message.id)\r\n    print(message.subject)\r\n    print(message.body)\r\n    print(message.text_body)\r\n    print(message.html_body)\r\n    print(message.attachments)\r\n    print(message.date)\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n### Downloading an attachment\r\n\r\nYou can download an attachment from a message in the inbox of a specified email address using the download_attachment method like this:\r\n\r\n```python\r\nimport asyncio\r\nimport secmail\r\n\r\nasync def main():\r\n    client = secmail.AsyncClient()\r\n    address = \"bobby-bob@kzccv.com\"\r\n    inbox = await client.get_inbox(address)\r\n    message_id = inbox[0].id\r\n    message = await client.get_message(address, message_id)\r\n    attachment_filename = message.attachments[0].filename\r\n    await client.download_attachment(address, message_id, attachment_filename)\r\n\r\nasyncio.run(main())\r\n\r\n>>> 'Path: (C:\\Users\\user\\path/config/rocket.png), Size: 49071B'\r\n```\r\n\r\n## Licnese\r\n\r\nThis software is licensed under the [MIT](https://github.com/qvco/1secMail-Python/blob/master/LICENSE) \u00a9 [Qvco](https://github.com/qvco).\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\ud83d\udce7 Simple and intuitive, yet full featured API wrapper for www.1secmail.com, supporting both synchronous and asynchronous operations.",
    "version": "1.2.0",
    "project_urls": {
        "Download": "https://github.com/qvco/1secMail-Python",
        "Homepage": "https://github.com/qvco/1secMail-Python"
    },
    "split_keywords": [
        "1secmail",
        "onesecmail",
        "tempmail",
        "disposable",
        "temporary",
        "email",
        "api",
        "wrapper",
        "library",
        "async",
        "asynchronous"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93847a6bbe6c03787579920b4407f8ddb6551a948405a41362de31bce6ab237c",
                "md5": "264136ca4729b652fd9814d960996c63",
                "sha256": "9e2e01fd8ed95abab90de2ec5dbf8f6e0687398ba90583d01b0d39c322aa008a"
            },
            "downloads": -1,
            "filename": "1secMail-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "264136ca4729b652fd9814d960996c63",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8741,
            "upload_time": "2023-12-20T06:22:23",
            "upload_time_iso_8601": "2023-12-20T06:22:23.409604Z",
            "url": "https://files.pythonhosted.org/packages/93/84/7a6bbe6c03787579920b4407f8ddb6551a948405a41362de31bce6ab237c/1secMail-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d3cb9908c2735deef9b2ddc94c64c2709a9724495da4884fe4e1954196310266",
                "md5": "e99d7d1765c5225c9e44aac9301bf044",
                "sha256": "169955e6239aa2b3e039388dae0a4f6d26ef4f0a86806562c0b21be79d78450c"
            },
            "downloads": -1,
            "filename": "1secMail-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e99d7d1765c5225c9e44aac9301bf044",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8361,
            "upload_time": "2023-12-20T06:22:25",
            "upload_time_iso_8601": "2023-12-20T06:22:25.329032Z",
            "url": "https://files.pythonhosted.org/packages/d3/cb/9908c2735deef9b2ddc94c64c2709a9724495da4884fe4e1954196310266/1secMail-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-20 06:22:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "qvco",
    "github_project": "1secMail-Python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "httpx",
            "specs": [
                [
                    ">=",
                    "0.17.1"
                ]
            ]
        }
    ],
    "lcname": "1secmail"
}
        
Elapsed time: 0.15941s