Skip to main content

python-mailtrap-handler

GitHub License pre-commit CircleCI PyPI version Quality Gate Status Maintainability Rating Security Rating

Implementation for MailTrap basic functionalities using Python.

Requirements

All you need is Python version 3.6 or above

Installation

pip3 install mailtrap-handler

Usage

For dedicated documentation click here

from mailtrap_handler import MailTrapHandler

mailtrap = MailTrapHandler(TOKEN, ACCOUNT_ID)
# then do what you need with the mailtrap object

Functions

Get mail id:

# default value for title is None
list_of_ids = mailtrap.get_mail_id(inbox, email, title="Some Title here")
# returns a list of found mails ids

Get mail html content:

# default value for title is None
# default value for waiting_time is 0
MailTrapHandler.get_mail(inbox, email, title, waiting_time=30)
# returns mail html content

Clean the inbox:

MailTrapHandler.clean_inbox(inbox)

Delete target mail:

MailTrapHandler.delete_mail(inbox, email, title="Some Title here")
# default value for title is None

Example Code

from mailtrap_handler import MailTrapHandler

# requirements
token = "123wellthiswouldbeyourtokenhere098"
account_id = 987654
inbox = 12349876  # this is your mailtrap inbox id
email = "target_email+probably_with_some_alias@inbox.mailtrap.io"
title = "Oy! Congrats on getting Your new T-shirt"

# creating mailtraphandler object
mailtrap = MailTrapHandler(token, account_id)

# getting the html content
mails = mailtrap.get_mail(inbox, email, title=title, 10)

# we do now whatever we need with the recieved mails
# and now we delete this mail
mailtrap.delete_mail(inbox, email, title=title)

# you know what let's just delete every mail in the inbox
mailtrap.clean_inbox(inbox)

# I got no more mails!

How to Contribute

We welcome issues to and pull requests against this repository!

Commit Message Convention

This repository follows Conventional Commits

Format

<type>(optional scope): <description> Example: feat(pre-event): Add speakers section

1. Type

Available types are:

  • feat → Changes about addition or removal of a feature. Ex: feat: Add table on landing page , feat: Remove table from landing page
  • fix → Bug fixing, followed by the bug. Ex: fix: Illustration overflows in mobile view
  • docs → Update documentation (README.md)
  • style → Updating style, and not changing any logic in the code (reorder imports, fix whitespace, remove comments)
  • chore → Installing new dependencies, or bumping deps
  • refactor → Changes in code, same output, but different approach
  • ci → Update github workflows, husky
  • test → Update testing suite, cypress files
  • revert → when reverting commits
  • perf → Fixing something regarding performance (deriving state, using memo, callback)

2. Optional Scope

Labels per page Ex: feat(pre-event): Add date label

If there is no scope needed, you don't need to write it

3. Description

Description must fully explain what is being done.

Add BREAKING CHANGE in the description if there is a significant change.

If there are multiple changes, then commit one by one

  • After colon, there are a single space Ex: feat: Add something
  • When using fix type, state the issue Ex: fix: File size limiter not working
  • Use imperative, dan present tense: "change" not "changed" or "changes"
  • Use capitals in front of the sentence
  • Don't add full stop (.) at the end of the sentence

Publish new release

Commit according to semantic release spec above and let CircleCI (and semantic-release) do the magic.

Metadata

Release files for mailtrap-handler 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mailtrap-handler 0.2
File Size Uploaded
mailtrap_handler-0.2.tar.gz 4.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for mailtrap-handler 0.2
File Interpreter ABI Platform
mailtrap_handler-0.2.0-py3-none-any.whl Python 3 none any Details
mailtrap_handler-0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / mailtrap_handler-0.2.tar.gz

Download URL mailtrap_handler-0.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d2052311721cee65f452bc77308a89c945edfcde5ba8f8e40d837d13f2493caf
BLAKE2b-256 checksum
How to use checksums
be39148bdb78a1b8be58d3287fc70da925f58e6c910f680e7c9ed57150800a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / mailtrap_handler-0.2.0-py3-none-any.whl

Download URL mailtrap_handler-0.2.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f3fa0e7396bc5a6736a559aa92d51049e7cd1d8f37b1c1018ab3e7cbcd7af0f
BLAKE2b-256 checksum
How to use checksums
b8ca2112ff8898a71e302afb80dd3214c55b5f16ecefcc0f450be23ecb5610dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / mailtrap_handler-0.2-py3-none-any.whl

Download URL mailtrap_handler-0.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cf34cf0c0362431700acafdbab0c9c15604c66dbc02507d167b90d08329ee65
BLAKE2b-256 checksum
How to use checksums
41ab09afc91fe0d16053f6285d3d107f70027938c1fec2fe57d56b8a28dcb471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.2 This release

3 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page