Python Temp Email Library
tempmail-python is a Python library for generating and managing temporary email addresses using the 1secmail service. It provides functions for creating email addresses, checking for new messages, and retrieving message contents.
Installation
You can install tempmail-python using pip:
pip install tempmail-python
Or you can install it from source:
pip install git+https://github.com/cubicbyte/tempmail-python.git
Examples
Receive a message (e.g. activation code)
from tempmail import EMail
email = EMail()
print(email.address) # qwerty123@1secmail.com
# ... request some email ...
msg = email.wait_for_message()
print(msg.body) # Hello World!\n
Get all messages in the inbox
from tempmail import EMail
email = EMail('example@1secmail.com')
inbox = email.get_inbox()
for msg_info in inbox:
print(msg_info.subject, msg_info.message.body)
Download an attachment
from tempmail import EMail
email = EMail(username='example', domain='1secmail.com')
msg = email.wait_for_message()
if msg.attachments:
attachment = msg.attachments[0]
data = attachment.download()
# Print
print(data) # b'Hello World!\n'
print(data.decode('utf-8')) # Hello World!\n
# Save to file
with open(attachment.filename, 'wb') as f:
f.write(data)
Get reddit activation code
from tempmail import EMail
def reddit_filter(msg):
return (msg.from_addr == 'noreply@reddit.com' and
msg.subject == 'Verify your Reddit email address')
email = EMail(address='redditaccount@1secmail.com')
msg = email.wait_for_message(filter=reddit_filter)
# get_activation_code(html=msg.html_body)
Some other features:
from tempmail.providers import OneSecMail
email = OneSecMail()
# request_email(email=email.address)
# Speed up inbox refresh rate
OneSecMail.inbox_update_interval = 0.1 # every 100ms
# Accept only emails with a specific subject, raise error after 60 seconds
msg = email.wait_for_message(timeout=60, filter=lambda m: m.subject == 'Hello World!')
print(msg.body)
License
tempmail-python is licensed under the MIT License. See the LICENSE file for more information.
Metadata
Release files for tempmail-python 2.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tempmail-python-2.3.3.tar.gz | 5.1 kB | Without provenance | Details for tempmail-python-2.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tempmail_python-2.3.3-py3-none-any.whl | Python 3 | none | any | Details for tempmail_python-2.3.3-py3-none-any.whl |
Total release size: 11.0 kB
Release files / tempmail-python-2.3.3.tar.gz
| Download URL | tempmail-python-2.3.3.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b289538758384e1d0967de6fb30e2a3c1af03daa0a1fa5ccd1154f62a0e312e
|
|
BLAKE2b-256 checksum How to use checksums |
15335b16ae0099ce7e93be50f646d0f5d9136e0091573bc34ffafb8cdeb021f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / tempmail_python-2.3.3-py3-none-any.whl
| Download URL | tempmail_python-2.3.3-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76c3cebae893a4f0caa0782d2dbc536df79b78948d523c0a18201b364860ac88
|
|
BLAKE2b-256 checksum How to use checksums |
b864ed9b69bf82df5bbf5d2e3bb3001ede1bd712d84008aaed90c41583762d1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for tempmail-python 2.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.