summaryrefslogtreecommitdiffstats
path: root/forefront/mail.py
diff options
context:
space:
mode:
authort.me/xtekky <98614666+xtekky@users.noreply.github.com>2023-04-27 20:16:07 +0200
committert.me/xtekky <98614666+xtekky@users.noreply.github.com>2023-04-27 20:16:07 +0200
commit10104774c10cccf95bbebcafd17c0a85207583e0 (patch)
tree6fec52831117ee43fe7141a153b7e123ff09d469 /forefront/mail.py
parent_ (diff)
parentMerge pull request #205 from AymaneHrouch/reformat__code (diff)
downloadgpt4free-10104774c10cccf95bbebcafd17c0a85207583e0.tar
gpt4free-10104774c10cccf95bbebcafd17c0a85207583e0.tar.gz
gpt4free-10104774c10cccf95bbebcafd17c0a85207583e0.tar.bz2
gpt4free-10104774c10cccf95bbebcafd17c0a85207583e0.tar.lz
gpt4free-10104774c10cccf95bbebcafd17c0a85207583e0.tar.xz
gpt4free-10104774c10cccf95bbebcafd17c0a85207583e0.tar.zst
gpt4free-10104774c10cccf95bbebcafd17c0a85207583e0.zip
Diffstat (limited to '')
-rw-r--r--forefront/mail.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/forefront/mail.py b/forefront/mail.py
index 64694e74..41c2a647 100644
--- a/forefront/mail.py
+++ b/forefront/mail.py
@@ -1,6 +1,8 @@
-from requests import Session
-from string import ascii_letters
from random import choices
+from string import ascii_letters
+
+from requests import Session
+
class Mail:
def __init__(self, proxies: dict = None) -> None:
@@ -23,27 +25,27 @@ class Mail:
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8"
}
-
+
def get_mail(self) -> str:
token = ''.join(choices(ascii_letters, k=14)).lower()
- init = self.client.post("https://api.mail.tm/accounts", json={
- "address" : f"{token}@bugfoo.com",
+ init = self.client.post("https://api.mail.tm/accounts", json={
+ "address": f"{token}@bugfoo.com",
"password": token
})
-
+
if init.status_code == 201:
- resp = self.client.post("https://api.mail.tm/token", json = {
+ resp = self.client.post("https://api.mail.tm/token", json={
**init.json(),
"password": token
})
-
+
self.client.headers['authorization'] = 'Bearer ' + resp.json()['token']
-
+
return f"{token}@bugfoo.com"
-
+
else:
raise Exception("Failed to create email")
-
+
def fetch_inbox(self):
return self.client.get(f"https://api.mail.tm/messages").json()["hydra:member"]
@@ -52,4 +54,3 @@ class Mail:
def get_message_content(self, message_id: str):
return self.get_message(message_id)["text"]
-