Skip to content

MrNom4ik/OneSecMailWapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OneSecMailWapper

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)

Install

python setup.py install

Examples

from OneSecMailWapper import get_domians, get_mailbox, Mailbox, Mail, Attachment

Mailbox

Get domians

domians: List[str] = get_domians()

Get specific mailbox

mailbox: Mailbox = get_mailbox("0ad1ekwui8", "qiott.com")

or

mailbox: Mailbox = get_mailbox("[email protected]")

Get random mailbox

mailbox: Mailbox = get_mailbox()

Mails

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

Get mails

You can get all mails with Mailbox.get_mails():

mails: List[Mail] = mailbox.get_mails()

Wait mail

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.

Attachments

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'))

About

Sync wapper over https://www.1secmail.com API temporary mail service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages