Skip to content

Commit 61e4073

Browse files
committed
providers.py: Added direct email support in constructor
1 parent 43dbe60 commit 61e4073

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tempmail/providers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
class OneSecMail:
1313
"""1secmail.com API wrapper"""
1414

15-
def __init__(self, username: str | None = None, domain: str | None = None) -> None:
16-
self.session = requests.Session()
17-
self.username = username or utils.random_string(10)
15+
def __init__(self, email: str | None = None, username: str | None = None, domain: str | None = None) -> None:
16+
if email is not None:
17+
username, domain = email.split('@')
1818

1919
if domain is not None and domain not in self.get_domains():
2020
raise ValueError(f'Invalid domain: {domain}')
2121

22+
self.session = requests.Session()
23+
self.username = username or utils.random_string(10)
2224
self.domain = domain or random.choice(self.get_domains())
2325

2426
def get_inbox(self) -> list['OneSecMail.MessageInfo']:

0 commit comments

Comments
 (0)