get-mail-tm 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- get_mail_tm-0.1.0/PKG-INFO +34 -0
- get_mail_tm-0.1.0/README.md +19 -0
- get_mail_tm-0.1.0/get_mail/__init__.py +4 -0
- get_mail_tm-0.1.0/get_mail/core.py +56 -0
- get_mail_tm-0.1.0/get_mail_tm.egg-info/PKG-INFO +34 -0
- get_mail_tm-0.1.0/get_mail_tm.egg-info/SOURCES.txt +9 -0
- get_mail_tm-0.1.0/get_mail_tm.egg-info/dependency_links.txt +1 -0
- get_mail_tm-0.1.0/get_mail_tm.egg-info/requires.txt +1 -0
- get_mail_tm-0.1.0/get_mail_tm.egg-info/top_level.txt +1 -0
- get_mail_tm-0.1.0/setup.cfg +4 -0
- get_mail_tm-0.1.0/setup.py +18 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: get-mail-tm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Temp mail generator using mail.tm API
|
|
5
|
+
Author: Bayu Putra Tama
|
|
6
|
+
Requires-Python: >=3.6
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: description
|
|
11
|
+
Dynamic: description-content-type
|
|
12
|
+
Dynamic: requires-dist
|
|
13
|
+
Dynamic: requires-python
|
|
14
|
+
Dynamic: summary
|
|
15
|
+
|
|
16
|
+
# get-mail
|
|
17
|
+
|
|
18
|
+
Temp mail generator using mail.tm API.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
`pip install get-mail`
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
```python
|
|
25
|
+
from get_mail import MailTM
|
|
26
|
+
|
|
27
|
+
mail = MailTM()
|
|
28
|
+
account = mail.create_account()
|
|
29
|
+
print(f"Address : {account['address']}")
|
|
30
|
+
print(f"Password: {account['password']}")
|
|
31
|
+
|
|
32
|
+
inbox = mail.get_messages()
|
|
33
|
+
for msg in inbox:
|
|
34
|
+
print(msg['subject'])
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# get-mail
|
|
2
|
+
|
|
3
|
+
Temp mail generator using mail.tm API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
`pip install get-mail`
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
```python
|
|
10
|
+
from get_mail import MailTM
|
|
11
|
+
|
|
12
|
+
mail = MailTM()
|
|
13
|
+
account = mail.create_account()
|
|
14
|
+
print(f"Address : {account['address']}")
|
|
15
|
+
print(f"Password: {account['password']}")
|
|
16
|
+
|
|
17
|
+
inbox = mail.get_messages()
|
|
18
|
+
for msg in inbox:
|
|
19
|
+
print(msg['subject'])
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import random
|
|
3
|
+
import string
|
|
4
|
+
|
|
5
|
+
class MailTM:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self.base_url = "https://api.mail.tm"
|
|
8
|
+
self.address = None
|
|
9
|
+
self.password = None
|
|
10
|
+
self.token = None
|
|
11
|
+
|
|
12
|
+
def _generate_string(self, length=10):
|
|
13
|
+
letters = string.ascii_lowercase + string.digits
|
|
14
|
+
return ''.join(random.choice(letters) for i in range(length))
|
|
15
|
+
|
|
16
|
+
def get_domain(self):
|
|
17
|
+
res = requests.get(f"{self.base_url}/domains")
|
|
18
|
+
if res.status_code == 200:
|
|
19
|
+
return res.json()['hydra:member'][0]['domain']
|
|
20
|
+
raise Exception("Failed to fetch domain")
|
|
21
|
+
|
|
22
|
+
def create_account(self):
|
|
23
|
+
domain = self.get_domain()
|
|
24
|
+
self.address = f"{self._generate_string()}@{domain}"
|
|
25
|
+
self.password = self._generate_string(12)
|
|
26
|
+
|
|
27
|
+
payload = {"address": self.address, "password": self.password}
|
|
28
|
+
res = requests.post(f"{self.base_url}/accounts", json=payload)
|
|
29
|
+
if res.status_code != 201:
|
|
30
|
+
raise Exception("Failed to create account")
|
|
31
|
+
|
|
32
|
+
token_res = requests.post(f"{self.base_url}/token", json=payload)
|
|
33
|
+
if token_res.status_code == 200:
|
|
34
|
+
self.token = token_res.json()['token']
|
|
35
|
+
return {
|
|
36
|
+
"address": self.address,
|
|
37
|
+
"password": self.password,
|
|
38
|
+
"token": self.token
|
|
39
|
+
}
|
|
40
|
+
raise Exception("Failed to get token")
|
|
41
|
+
|
|
42
|
+
def get_messages(self):
|
|
43
|
+
if not self.token:
|
|
44
|
+
return []
|
|
45
|
+
headers = {"Authorization": f"Bearer {self.token}"}
|
|
46
|
+
res = requests.get(f"{self.base_url}/messages", headers=headers)
|
|
47
|
+
if res.status_code == 200:
|
|
48
|
+
return res.json()['hydra:member']
|
|
49
|
+
return []
|
|
50
|
+
|
|
51
|
+
def get_message_content(self, msg_id):
|
|
52
|
+
headers = {"Authorization": f"Bearer {self.token}"}
|
|
53
|
+
res = requests.get(f"{self.base_url}/messages/{msg_id}", headers=headers)
|
|
54
|
+
if res.status_code == 200:
|
|
55
|
+
return res.json()
|
|
56
|
+
return None
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: get-mail-tm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Temp mail generator using mail.tm API
|
|
5
|
+
Author: Bayu Putra Tama
|
|
6
|
+
Requires-Python: >=3.6
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
Dynamic: author
|
|
10
|
+
Dynamic: description
|
|
11
|
+
Dynamic: description-content-type
|
|
12
|
+
Dynamic: requires-dist
|
|
13
|
+
Dynamic: requires-python
|
|
14
|
+
Dynamic: summary
|
|
15
|
+
|
|
16
|
+
# get-mail
|
|
17
|
+
|
|
18
|
+
Temp mail generator using mail.tm API.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
`pip install get-mail`
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
```python
|
|
25
|
+
from get_mail import MailTM
|
|
26
|
+
|
|
27
|
+
mail = MailTM()
|
|
28
|
+
account = mail.create_account()
|
|
29
|
+
print(f"Address : {account['address']}")
|
|
30
|
+
print(f"Password: {account['password']}")
|
|
31
|
+
|
|
32
|
+
inbox = mail.get_messages()
|
|
33
|
+
for msg in inbox:
|
|
34
|
+
print(msg['subject'])
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
get_mail
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="get-mail-tm",
|
|
8
|
+
version="0.1.0",
|
|
9
|
+
author="Bayu Putra Tama",
|
|
10
|
+
description="Temp mail generator using mail.tm API",
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type="text/markdown",
|
|
13
|
+
packages=find_packages(),
|
|
14
|
+
install_requires=[
|
|
15
|
+
"requests"
|
|
16
|
+
],
|
|
17
|
+
python_requires='>=3.6',
|
|
18
|
+
)
|