Skip to content

Instantly share code, notes, and snippets.

@wwhtrbbtt
Created October 12, 2020 22:43
Show Gist options
  • Save wwhtrbbtt/d021b2930fd963596aae8939f65f2451 to your computer and use it in GitHub Desktop.
Save wwhtrbbtt/d021b2930fd963596aae8939f65f2451 to your computer and use it in GitHub Desktop.
import requests
import time
"""
Docs:
example:
m = mail()
print(m.mail)
# get the temp mail adress
print(m.messages)
# empty list
mails = m.update_messages()
# update your mails
print(mails[0])
# print the first mail
# also possible with (without updating):
print(m.messages[0])
m.reset_time()
# reset the time back to 600 secs
timeLeft = m.seconds_left()
print(timeLeft)
# how many seconds you have left
"""
class mail():
def __init__(self):
self.session = requests.Session()
self.messages = []
self.mail = self.get_mail()
def get_mail(self):
r = self.session.get("https://10minutemail.com/session/address")
if r.status_code == 200:
return r.json()["address"]
def reset_time(self):
r = self.session.get("https://10minutemail.com/session/reset")
if r.status_code == 200 and r.json()["Response"] == "reset":
return
def seconds_left(self):
r = self.session.get("https://10minutemail.com/session/secondsLeft")
if r.status_code == 200:
return r.json()["secondsLeft"]
def update_messages(self):
r = self.session.get("https://10minutemail.com/messages/messagesAfter/0")
mails = []
if r.status_code == 200:
for mail in r.json():
mails.append({
"sender": mail["sender"],
"subject": mail["subject"],
"html": mail["bodyHtmlContent"],
"text": mail["bodyPlainText"]
})
self.messages = mails
return self.messages
m = mail()
print(m.mail)
while True:
print(m.update_messages())
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment