-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecMail.py
100 lines (93 loc) · 3.21 KB
/
recMail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import requests
import time
from config import Config
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3",
"x-rapidapi-ua": "RapidAPI-Playground",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site"
}
async def get_key():
try:
response = requests.post(
"https://smailpro.com/app/key",
json={
"domain": "gmail.com",
"username": "random",
"server": "server-1",
"type": "alias"
},
headers=headers,
cookies={}
)
response.raise_for_status()
return response.json().get('items')
except requests.exceptions.RequestException as error:
print(f"Error: {error}")
async def get_email():
try:
key = await get_key()
response = requests.get(
f"https://api.sonjj.com/email/gm/get",
params={
"key": key,
"domain": "gmail.com",
"username": "random",
"server": "server-1",
"type": "alias"
},
headers=headers
)
response.raise_for_status()
return response.json().get('items')
except requests.exceptions.RequestException as error:
print(f"Error: {error}")
async def get_mid(email):
await delay(10000)
try:
key = await get_key()
response = requests.get(
f"https://api.sonjj.com/email/gm/check",
params={
"key": key,
'rapidapi-key': 'f871a22852mshc3ccc49e34af1e8p126682jsn734696f1f081',
"email": email['email'],
"timestamp": email['timestamp']
},
headers=headers
)
response.raise_for_status()
return response.json()['items'][0]['mid']
except requests.exceptions.RequestException as error:
print(f"Error: {error}")
return await get_mid(email)
async def get_message(email):
try:
print("Waiting for Email Code...")
mid = await get_mid(email)
print("Email Code Received!")
key = await get_key()
response = requests.get(
f"https://api.sonjj.com/email/gm/read",
params={
"key": key,
'rapidapi-key': 'f871a22852mshc3ccc49e34af1e8p126682jsn734696f1f081',
"email": email['email'],
"message_id": mid
},
headers=headers
)
response.raise_for_status()
security_code_match = re.search(r'>\s*(\d{6})\s*<\/span>', response.text)
if security_code_match:
return security_code_match.group(1)
except requests.exceptions.RequestException as error:
print(f"Error: {error}")
async def delay(time_ms):
time.sleep(time_ms / 1000)
# To use the recovery email specified in config.py:
async def get_recovery_email():
return {"email": Config.RECOVERY_EMAIL}