temp-mails

raw JSON →
2.2.0 verified Mon Apr 27 auth: no python

A basic wrapper around various temp mail sites (mail.tm, guerrillamail, etc.) providing a unified API. Current version 2.2.0, requires Python >=3.8. Active development with regular releases.

pip install temp-mails
error ModuleNotFoundError: No module named 'temp_mails'
cause Import path is 'tempmail', not 'temp_mails'.
fix
Change import to: from tempmail import Mail
error ImportError: cannot import name 'TempMail' from 'tempmail'
cause Class renamed from TempMail to Mail in v2.
fix
Use: from tempmail import Mail
gotcha The package name on PyPI is 'temp-mails' but the import uses 'tempmail'. Many users mistakenly import 'temp_mails' or 'temp-mails'.
fix Use 'from tempmail import ...'.
breaking In version 2.x, the API changed significantly from 1.x. The main class is now 'Mail' instead of 'TempMail', and methods like 'wait_for_email' replaced 'get_inbox'.
fix Update code to use new API: from tempmail import Mail; mail = Mail(); mail.wait_for_email()
gotcha The 'wait_for_email' method can hang indefinitely if timeout not set. Always provide a timeout parameter.
fix Use mail.wait_for_email(timeout=30) instead of no timeout.

Create a temporary email, display address, and wait for an incoming email.

from tempmail import Mail

mail = Mail()
print(mail.address)

# Wait for email
email = mail.wait_for_email(timeout=30)
if email:
    print(email.subject)