Skip to main content

A Python wrapper for the Emailnator temporary email service.

Project description

Emailnator

Emailnator is a Python wrapper for the Emailnator temporary email service. It provides a convenient way to generate temporary email addresses, retrieve inbox messages, and fetch individual messages.

Installation

To install the Emailnator package, simply run:

pip install emailnator

TODO

To install the Emailnator package for development purposes, follow these steps:

  1. Clone the repository to your local machine using the command:
git clone https://github.com/repollo/Emailnator.git
  1. Navigate to the cloned repository directory:
cd Emailnator
  1. Create a virtual environment for the project:
python -m venv venv
  1. Activate the virtual environment:
source venv/bin/activate

Note: If you are using Windows, use the following command instead:

venv\Scripts\activate
  1. Install the required dependencies using pip:
pip install -r requirements.txt
  1. Install the package in development mode:
pip install -e .

This will install the package in editable mode, allowing you to modify the source code and see the changes reflected immediately.

Usage

First, import the Emailnator class:

from emailnator import Emailnator

Then, create an Emailnator instance:

emailnator = Emailnator()

By default, the .env file containing authentication tokens will be created in the same directory as the emailnator.py file. You can specify a custom directory using the env_path parameter:

custom_path = "/path/to/your/custom/directory"
emailnator = Emailnator(env_path=custom_path)

Generate a temporary email address

email_data = emailnator.generate_email()
email_address = email_data["email"][0]
print(email_address)

Retrieve inbox messages

inbox_data = emailnator.inbox(email_address)
print(inbox_data)

Get a specific message

message_id = inbox_data["messageData"][3]["messageID"]
message_data = emailnator.get_message(email_address, message_id)
print(message_data)

Example

from emailnator import Emailnator

emailnator = Emailnator()

# Generate an email
email_data = emailnator.generate_email()
email = email_data["email"][0]

# Get existing email if generated before.
email = emailnator.get_existing_email()

# Get email inbox of email
emails = emailnator.inbox(email)

# Select a specific email message id
message_id = emails["messageData"][1]["messageID"]
    
# Get the email message id contents
email_content = emailnator.get_message(email, message_id)

License

This project is licensed under the MIT License.

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

emailnator-0.1.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

emailnator-0.1.1-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

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