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.
You can install it using pip:
pip install TestMailHelper
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()
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.
'from'
, 'subject'
, 'tag'
, 'timestamp'
, 'id'
.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.None
if not found.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.'from'
, 'subject'
, 'tag'
, 'timestamp'
, 'id'
.requests.exceptions.RequestException
if the request fails.Contributions are welcome! Please open an issue or submit a pull request if you have suggestions or improvements.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or support, please contact Muhammad Ali.