tempmail python
2.3.3 - Python 3.7+ support
tempmail-python ist eine Python-Bibliothek zum Generieren und Verwalten temporärer E-Mail-Adressen mithilfe des 1secmail-Dienstes. Es bietet Funktionen zum Erstellen von E-Mail-Adressen, zum Prüfen auf neue Nachrichten und zum Abrufen von Nachrichteninhalten.
Sie können tempmail-python mit pip installieren:
pip install tempmail-python
Oder Sie können es von der Quelle installieren:
pip install git+https://github.com/cubicbyte/tempmail-python.git
Eine Nachricht erhalten (z. B. Aktivierungscode)
from tempmail import EMail
email = EMail ()
print ( email . address ) # [email protected]
# ... request some email ...
msg = email . wait_for_message ()
print ( msg . body ) # Hello World!n
Erhalten Sie alle Nachrichten im Posteingang
from tempmail import EMail
email = EMail ( '[email protected]' )
inbox = email . get_inbox ()
for msg_info in inbox :
print ( msg_info . subject , msg_info . message . body )
Laden Sie einen Anhang herunter
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 )
Holen Sie sich den Reddit-Aktivierungscode
from tempmail import EMail
def reddit_filter ( msg ):
return ( msg . from_addr == '[email protected]' and
msg . subject == 'Verify your Reddit email address' )
email = EMail ( address = '[email protected]' )
msg = email . wait_for_message ( filter = reddit_filter )
# get_activation_code(html=msg.html_body)
Einige andere Funktionen:
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 )
tempmail-python ist unter der MIT-Lizenz lizenziert. Weitere Informationen finden Sie in der LICENSE-Datei.