Skip to main content

Mail Ship: A powerful Python library for email automation and testing. It offers Gmail integration, real-time inbox monitoring, content extraction, and seamless Selenium integration. Perfect for developers navigating complex email-based workflows and testing scenarios.

Project description

Here’s a more concise and focused README.md tailored specifically for the PyPI package, including a link to the GitHub repository for detailed documentation.


MailShip

PyPI version
MailShip is a Python library designed to simplify Gmail automation for developers and testers. It offers tools for email generation, email content extraction, and seamless integration with CI/CD pipelines and testing frameworks.

Features

  • Generate unique email addresses for testing.
  • Wait for and retrieve emails in real time.
  • Extract tokens and links from email content.
  • Perform regex-based searches on email content.
  • Automatically refresh Gmail API tokens via cron jobs or pipelines.
  • CI/CD ready with GitHub Actions integration.

Installation

Install the library using pip:

pip install mail-ship

Getting Started

After installing the package, you can initialize the setup process:

Step 1: Setup Gmail Authentication

Run the following command to set up your Gmail API credentials:

mail-ship-setup

This will guide you through the setup process, including storing credentials and setting environment variables.

Step 2: Set Up Automatic Token Refreshing

  • To set up a cron job (Linux/macOS) for automatic token refreshing, run:
    mail-ship-setup --setup-cron
    
  • To set up a scheduled task (Windows), run:
    mail-ship-setup --setup-task
    

For more detailed setup instructions, visit the GitHub repository.


Basic Usage

Here’s a quick example of how to use MailShip:

from mailship import GmailAutomator

automator = GmailAutomator(verbose=True)

# Generate a unique email for testing
email = automator.generate_email()
print(f"Generated email: {email}")

# Wait for an email
received_email = automator.wait_for_email(email, timeout=120)

if received_email:
    print(f"Received email: {received_email['subject']}")
    # Extract a token from the email
    token = automator.extract_token(received_email)
    print(f"Extracted token: {token}")
else:
    print("No email received within the timeout period.")

CI/CD Integration

MailShip is designed to work seamlessly in CI/CD pipelines. Add the following step in your GitHub Actions workflow to refresh Gmail API tokens:

- name: Refresh Tokens
  env:
    GMAIL_CLIENT_ID: ${{ secrets.GMAIL_CLIENT_ID }}
    GMAIL_CLIENT_SECRET: ${{ secrets.GMAIL_CLIENT_SECRET }}
    GMAIL_AUTH_REFRESH_TOKEN: ${{ secrets.GMAIL_AUTH_REFRESH_TOKEN }}
    GMAIL_AUTH_SALT: ${{ secrets.GMAIL_AUTH_SALT }}
  run: python -m mailship.setup_auth --refresh-tokens

Documentation

For detailed documentation, advanced features, and contributing guidelines, visit the GitHub repository.


License

This project is licensed under a Custom Repository License. See the GitHub repository for details.


Contact

For questions or support, reach out on:


This README.md is concise, focused on installation and usage, and directs users to the GitHub repository for in-depth information. Let me know if you’d like further refinements!

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

mailship-1.0.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

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

mailship-1.0.0-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file mailship-1.0.0.tar.gz.

File metadata

  • Download URL: mailship-1.0.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for mailship-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5f53e1e75b6a8aad55969ddcbf4e3d86b746d63109b6cbcc96c5841c047b6492
MD5 6639d2ce4cc603d18a13fa82225b84bb
BLAKE2b-256 3e29f39a91cd788dac1116841256c2182c4be47ca038e25ca791a9c4d89636c8

See more details on using hashes here.

File details

Details for the file mailship-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mailship-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for mailship-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b156651e34d4ec606e2da7b7bbb366a6e72ce64a03fb8ad75ae9d411ba6e01c
MD5 1a8c65700564727d5cbf59effe599100
BLAKE2b-256 3e549bdba7259c9e5967b7327eea7f1ad9d4c97cc862c5017cbe97c86845f079

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