Package: 1secMail
An API wrapper forwww.1secmail.comwritten in Python.AboutThis is an easy to use yet full-featured Python API wrapper forwww.1secmail.com↗ using the official 1secMail API. It allows you to easily create temporary email addresses for testing, verification, or other purposes where you need a disposable email address.Asynchronous operations are also supported!:thumbsup:InstallTo install the package, you'll need Python 3.8 or above installed on your computer. From your command line:pipinstall1secMailNoteIf you're willing to install the development version, do the following:gitclonehttps://github.com/qvco/1secMail-Python.gitcd1secMail-Python

pipinstall-rrequirements.txt

pipinstall-e.UsageGenerating Email AddressesTo generate a list of random email addresses, use therandom_email()method:importsecmailclient=secmail.Client()client.random_email(amount=3)>>>['c3fho3cry1@1secmail.net','5qcd3d36zr@1secmail.org','b6fgeothtg@1secmail.net']You can also generate a custom email address by specifying the username and domain:NoteSpecifying a domain is optional!client.custom_email(username="bobby-bob",domain="kzccv.com")>>>'bobby-bob@kzccv.com'Receiving MessagesTo wait until a new message is received, use theawait_new_message()method:message=client.await_new_message("bobby-bob@kzccv.com")To check all messages received on a particular email address, use theget_inbox()method and pass the email address:inbox=client.get_inbox("bobby-bob@kzccv.com")formessageininbox:print(message.id)print(message.from_address)print(message.subject)print(message.date)You can also fetch a single message using theget_message()method and passing the email address and message ID:message=client.get_message(address="bobby-bob@kzccv.com",message_id=235200687)print(message.id)print(message.subject)print(message.body)print(message.text_body)print(message.html_body)print(message.attachments)print(message.date)Downloading an attachmentYou can download an attachment from a message in the inbox of a specified email address using the download_attachment method like this:client.download_attachment(address,message_id,attachment_filename)>>>'Path: (C:\Users\user\path/config/rocket.png), Size: 49071B'Asynchronous ClientGenerating Email AddressesTo generate a list of random email addresses, use therandom_email()method:importasyncioimportsecmailasyncdefmain():client=secmail.AsyncClient()email_addresses=awaitclient.random_email(amount=3)print(email_addresses)asyncio.run(main())>>>['c3fho3cry1@1secmail.net','5qcd3d36zr@1secmail.org','b6fgeothtg@1secmail.net']You can also generate a custom email address by specifying the username and domain:NoteSpecifying a domain is optional!awaitclient.custom_email(username="bobby-bob",domain="kzccv.com")>>>'bobby-bob@kzccv.com'Receiving MessagesTo wait until a new message is received, use theawait_new_message()method:importasyncioimportsecmailasyncdefmain():client=secmail.AsyncClient()message=awaitclient.await_new_message("bobby-bob@kzccv.com")print(f"{message.from_address}:{message.subject}")asyncio.run(main())To check all messages received on a particular email address, use theget_inbox()method and pass the email address:importasyncioimportsecmailasyncdefmain():client=secmail.AsyncClient()inbox=awaitclient.get_inbox("bobby-bob@kzccv.com")print(f"You have{len(inbox)}messages in your inbox.")formessageininbox:print(message.id)print(message.from_address)print(message.subject)print(message.date)asyncio.run(main())You can also fetch a single message using theget_message()method and passing the email address and message ID:importasyncioimportsecmailasyncdefmain():client=secmail.AsyncClient()address="bobby-bob@kzccv.com"inbox=awaitclient.get_inbox(address)message_id=inbox[0].idmessage=awaitclient.get_message(address,message_id)print(message.id)print(message.subject)print(message.body)print(message.text_body)print(message.html_body)print(message.attachments)print(message.date)asyncio.run(main())Downloading an attachmentYou can download an attachment from a message in the inbox of a specified email address using the download_attachment method like this:importasyncioimportsecmailasyncdefmain():client=secmail.AsyncClient()address="bobby-bob@kzccv.com"inbox=awaitclient.get_inbox(address)message_id=inbox[0].idmessage=awaitclient.get_message(address,message_id)attachment_filename=message.attachments[0].filenameawaitclient.download_attachment(address,message_id,attachment_filename)asyncio.run(main())>>>'Path: (C:\Users\user\path/config/rocket.png), Size: 49071B'LicneseThis software is licensed under theMIT©Qvco.