Skip to main content

A Python package for interacting with the Testmail.app API.

Project description

TestMailHelper

TestMailHelper is a Python package designed for easy interaction with the Testmail.app API. It simplifies the process of retrieving email lists and fetching specific emails using the API.

Features

  • Retrieve a detailed list of emails from the Testmail API.
  • Fetch a specific email by its ID.
  • Retrieve emails filtered by a specific tag.

Installation

You can install it using pip:

pip install TestMailHelper

Usage

Here's a basic example of how to use the TMClient class provided by the TestMailHelper package:

from testmailhelper import TMClient

def main():
    client = TMClient(
        api_key='your_api_key',
        namespace='your_namespace'
    )
    
    # Get a list of emails
    emails = client.get_emails_list()
    print("Email List:")
    for email in emails:
        print(email)
    
    # Get a specific email by ID
    email_id = 'some_email_id'
    email = client.get_email_by_id(email_id)
    if email:
        print("Email Details:")
        print(email)
    else:
        print(f"No email found with ID: {email_id}")
    
    # Get emails by tag
    tag = 'some_tag'
    tagged_emails = client.get_emails_by_tag(tag)
    print(f"Emails with tag '{tag}':")
    for email in tagged_emails:
        print(email)

if __name__ == "__main__":
    main()

API Reference

TMClient

__init__(api_key, namespace)

Initialize the TMClient with your API key and namespace.

  • api_key (str): Your API key for the Testmail API.
  • namespace (str): The namespace for the Testmail API.

get_emails_list()

Retrieve a list of emails from the Testmail API.

  • Returns: A list of dictionaries, each representing an email with keys: 'from', 'subject', 'tag', 'timestamp', 'id'.
  • Raises: requests.exceptions.RequestException if the request fails.

get_email_by_id(email_id)

Retrieve a specific email by its ID.

  • email_id (str): The ID of the email to retrieve.
  • Returns: A dictionary representing the email, or None if not found.
  • Raises: requests.exceptions.RequestException if the request fails.

get_emails_by_tag(tag)

Retrieve a list of emails with a specific tag.

  • tag (str): The tag to filter emails by.
  • Returns: A list of dictionaries, each representing an email with keys: 'from', 'subject', 'tag', 'timestamp', 'id'.
  • Raises: requests.exceptions.RequestException if the request fails.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have suggestions or improvements.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or support, please contact Muhammad Ali.

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

testmailhelper-0.3.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TestMailHelper-0.3.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file testmailhelper-0.3.2.tar.gz.

File metadata

  • Download URL: testmailhelper-0.3.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for testmailhelper-0.3.2.tar.gz
Algorithm Hash digest
SHA256 cca390650f1598cb023989d8af57035b1771e810424734711454965efef7f3ea
MD5 3736b972f9f2e0fb4bdd2c59aaddb52f
BLAKE2b-256 0845c4799b708178dfdd86abbf7b6992a317ff1a07135d9be9dc67e71a75611d

See more details on using hashes here.

File details

Details for the file TestMailHelper-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: TestMailHelper-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for TestMailHelper-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9e0ce99840ecf973d909866ece23abab3c159b440c9299b3191ee78e80393a98
MD5 431ba47da073c67f53b14d0236260ada
BLAKE2b-256 d5dde8201ca71e671abf6e08416808fb12f0f31d82a0e132fd4daca5d081292e

See more details on using hashes here.

Supported by

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