| |
| import requests |
| import random |
| import string |
|
|
| BASE = "https://api.mail.tm" |
| VERSION = "1.0" |
|
|
| session = requests.Session() |
| email = None |
| password = None |
|
|
| def rand_str(n=10): |
| return ''.join(random.choices(string.ascii_lowercase + string.digits, k=n)) |
|
|
| def generate_email(): |
| global email, password |
|
|
| print("π‘ Fetching data...") |
| r = session.get(f"{BASE}/domains") |
| domain = r.json()["hydra:member"][0]["domain"] |
|
|
| email = f"{rand_str()}@{domain}" |
| password = rand_str(12) |
|
|
| |
| session.post(f"{BASE}/accounts", json={ |
| "address": email, |
| "password": password |
| }) |
|
|
| |
| token_res = session.post(f"{BASE}/token", json={ |
| "address": email, |
| "password": password |
| }) |
|
|
| token = token_res.json().get("token") |
| session.headers.update({"Authorization": f"Bearer {token}"}) |
|
|
| print("\nβ
Temporary email created!") |
| print(f"π Your temporary email address is:\n{email}") |
|
|
| def check_inbox(): |
| if not email: |
| print("β Generate email first") |
| return |
|
|
| print("π‘ Fetching data...") |
| r = session.get(f"{BASE}/messages") |
| msgs = r.json().get("hydra:member", []) |
|
|
| if not msgs: |
| print("π No messages") |
| return |
|
|
| print(f"\n㪠Inbox ({email})") |
| print("-" * 30) |
|
|
| for i, m in enumerate(msgs, 1): |
| print(f"{i}. {m['subject']}") |
| print(f" From: {m['from']['address']}") |
|
|
| |
| msg_id = m["id"] |
| full = session.get(f"{BASE}/messages/{msg_id}").json() |
| print(f" Message: {full.get('text', '')}") |
| print("-" * 30) |
|
|
| def menu(): |
| while True: |
| print("\nπ§ mail.tm Temporary Email Tool") |
| print("1. Generate a Temporary Email Address") |
| print("2. Check Inbox / Get Messages") |
| print("3. Check Version") |
| print("4. Exit") |
|
|
| choice = input("Enter your choice: ") |
|
|
| if choice == "1": |
| generate_email() |
|
|
| elif choice == "2": |
| check_inbox() |
|
|
| elif choice == "3": |
| print(f"π§ Version: {VERSION}") |
|
|
| elif choice == "4": |
| print("π Goodbye") |
| break |
|
|
| else: |
| print("β Invalid choice") |
|
|
| if __name__ == "__main__": |
| menu() |