Skip to content

Commit

Permalink
Fixed email domains
Browse files Browse the repository at this point in the history
  • Loading branch information
st1vms committed Oct 29, 2023
1 parent c179b59 commit d136c19
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions onesecmail_api/onesecmail_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class MailMessage:
html_body: str


__DOMAIN = "txcct.com"

__BASE_URL = "https://www.1secmail.com/api/v1/"


Expand All @@ -48,15 +46,20 @@ def get_domain_list() -> list[str]:
return http_get(__BASE_URL + endpoint, timeout=2).json()


def gen_random_emails(count: int = 1) -> list[str]:
"""Generate random emails"""
def gen_random_emails(count: int = 1, domain: str = None) -> list[str]:
"""Generate random emails, use `count` argument to change number of emails generated.
Use `domain` argument to override generated email domain"""

if count <= 0:
return ValueError("'count' must be positive")
endpoint = f"?action=genRandomMailbox&count={count}"
res = http_get(__BASE_URL + endpoint, timeout=2).json()
if not res:
return []
return list(map(lambda e: e.split("@", maxsplit=1)[0] + f"@{__DOMAIN}", res))
if not domain:
return res
return list(map(lambda e: e.split("@", maxsplit=1)[0] + f"@{domain}", res))


def fetch_mailbox(email: str) -> list[MailBoxMessage] | None:
Expand Down

0 comments on commit d136c19

Please sign in to comment.