OneSecMailWapper - sync wapper over https://www.1secmail.com API temporary mail service
See also: https://github.com/MrNom4ik/OneSecMailAsyncWapper (async version on the aiohttp
library)
python setup.py install
from OneSecMailWapper import get_domians, get_mailbox, Mailbox, Mail, Attachment
domians: List[str] = get_domians()
mailbox: Mailbox = get_mailbox("0ad1ekwui8", "qiott.com")
or
mailbox: Mailbox = get_mailbox("[email protected]")
mailbox: Mailbox = get_mailbox()
Initially, the API returns short mails, in order to receive the mails in full, you need to make an additional request to the API.
Mail fields:
id: int
from_adress: str
subject: str
date: datetime
attachments: List[Attachment]
body: str
textBody: str
htmlBody: str
You can get all mails with Mailbox.get_mails():
mails: List[Mail] = mailbox.get_mails()
If you need to receive an mail that is due soon, you can use Mailbox.wait_mail():
def check(mail: Mail) -> bool:
return mail.from_adress == "[email protected]"
mail: Mail = mailbox.wait_mail(check)
print(mail.body)
This method will create a while loop and will check for new mails every 5 seconds(default). Each new mail will be checked through check
and if the check is successful, the letter will be returned.
Attachment fields:
filename: str
content_type: str
size: int
You can get the content of an attachment with Attachment.get_content():
for attachment in mail.attachments:
print(attachment.get_content(), file=open(attachment.filename, 'wb'))