from flask import Flask, request, jsonify, render_template_string import random import string import time app = Flask(__name__) # In-memory storage (simulate persistence per session) mailboxes = {} premium_users = set() # Domains for temp emails DOMAINS = [ "temp-mail.org", "mail-temp.net", "10minutemail.com", "throwaway-mail.com", "fake-mail.net" ] # Sample email templates SAMPLE_EMAILS = [ { "from": "no-reply@facebook.com", "subject": "Confirm Your Email Address", "body": "

Click here to activate your account.

", "timestamp": time.time() - 300 # 5 mins ago }, { "from": "support@netflix.com", "subject": "Start Your Free Trial Now!", "body": "

Welcome! Your 30-day trial starts now.

", "timestamp": time.time() - 1200 # 20 mins ago }, { "from": "verify@hulu.com", "subject": "Your verification code: 48291", "body": "

Use code: 48291 to verify.

", "timestamp": time.time() - 60 # 1 min ago } ] # Generate random email def generate_email(): prefix = ''.join(random.choices(string.ascii_lowercase + string.digits, k=8)) domain = random.choice(DOMAINS) return f"{prefix}@{domain}" # HTML Template (Full Frontend) HTML_TEMPLATE = ''' Temp-Mail.org Clone

🔒 Temp-Mail.org

Temporary, secure, anonymous, free, disposable email address

Regenerate Mailbox
Want custom emails, no ads, multiple mailboxes? Upgrade to Premium

Login

Forgot Password?

Forgot Password

Back to Login

Inbox

''' # Routes @app.route('/') def index(): return render_template_string(HTML_TEMPLATE) @app.route('/new-mailbox', methods=['POST']) def new_mailbox(): # Simulate rate limit: max 5 mailboxes per session (in real app: use IP/session) ip = request.remote_addr if not hasattr(app, 'mailbox_count'): app.mailbox_count = {} if ip not in app.mailbox_count: app.mailbox_count[ip] = 0 app.mailbox_count[ip] += 1 if app.mailbox_count[ip] > 5: return jsonify({ "error": "Too many new mailboxes created. Upgrade to Premium or try again later.", "regenerate": True }), 429 email = generate_email() expiry = time.time() + 3600 # 1 hour emails = random.sample(SAMPLE_EMAILS, k=random.randint(0, 3)) # 0-3 emails mailboxes[email] = { "email": email, "created": time.time(), "expires": expiry, "emails": emails } return jsonify(mailboxes[email]) @app.route('/inbox/') def inbox(email): if email not in mailboxes: return jsonify({"error": "The target message is no longer available"}), 404 box = mailboxes[email] if time.time() > box['expires']: del mailboxes[email] return jsonify({"error": "Your mailbox is no longer available. We have generated a new mailbox for you", "regenerate": True}), 410 return jsonify(box) @app.route('/login', methods=['POST']) def login(): data = request.get_json() email = data.get('email') password = data.get('password') if not email or not password: return jsonify({"error": "Invalid user email or password"}), 400 # Simulate premium login if "premium" in email: premium_users.add(email) return jsonify({"success": True, "message": "Now you have premium subscription!"}) else: return jsonify({"error": "Premium subscription expired. You can not login to premium."}), 401 @app.route('/forgot-password', methods=['POST']) def forgot_password(): data = request.get_json() email = data.get('email') if not email: return jsonify({"error": "Something went wrong! Maybe you have entered an incorrect email"}), 400 # Simulate reset link sent return jsonify({"success": True}) # Run the app if __name__ == '__main__': print("🌐 Temp-Mail.org Demo Server Running at http://localhost:5000") app.run(host='0.0.0.0', port=5000, debug=True)