https://github.com/krypton-byte/xtempmail
📨 Disposable Email (Python Library)
https://github.com/krypton-byte/xtempmail
asynchronous autoreply disposable-email email library lightweight python tempmail tempmail-api temporary
Last synced: 5 months ago
JSON representation
📨 Disposable Email (Python Library)
- Host: GitHub
- URL: https://github.com/krypton-byte/xtempmail
- Owner: krypton-byte
- Created: 2021-11-05T08:54:29.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T09:01:01.000Z (about 2 years ago)
- Last Synced: 2024-10-07T09:17:42.625Z (12 months ago)
- Topics: asynchronous, autoreply, disposable-email, email, library, lightweight, python, tempmail, tempmail-api, temporary
- Language: Python
- Homepage: https://xtempmail.readthedocs.io/
- Size: 6.88 MB
- Stars: 21
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/krypton-byte/xtempmail/actions/workflows/typing.yml)
[](https://github.com/krypton-byte/xtempmail/actions/workflows/release.yml)
[](https://pepy.tech/project/xtempmail)
# Temporary Mail
Tempmail client for tempmail.plus## Installation
```python
$ pip install git+https://github.com/krypton-byte/xtempmail
```## Feature
- Custom Name/Mail
- Reply/send Message(support attachment file)
- Read Message (support Download attachment file)
- Delete message
- Destroy Inbox
- Lock Inbox
- Unlock Inbox
- Generate Secret Inbox
- Asynchronous
- Synchronous
## Example
```
example/main.py
```
## Usage Sync
```python
from xtempmail import Email, extension
import logging
from xtempmail.mail import EmailMessage, EMAIL
log = logging.getLogger('xtempmail')
log.setLevel(logging.INFO)
app = Email(name='krypton', ext=ext=EMAIL.MAILTO_PLUS))
@app.on.message()
def baca(data: EmailMessage):
print(f"\tFrom: {data.from_mail}\n\tSubject: {data.subject}\n\tBody: {data.text}\n\tReply -> Delete")
ok = []
for i in data.attachments: # -> Forward attachment
ok.append(( i.name, i.download()))
if data.from_is_local:
data.from_mail.send_message(data.subject, data.text, multiply_file=ok) # -> Forward message
data.delete() #delete message
@app.on.message(lambda msg:msg.attachments)
def get_message_media(data: EmailMessage):
print(f'Attachment: {[i.name for i in data.attachments]}')
@app.on.message(lambda x:x.from_mail.__str__().endswith('@gmail.com'))
def getGmailMessage(data: EmailMessage):
print(f'Gmail: {data.from_mail}')
if __name__ == '__main__':
try:
app.listen_new_message(1)
except KeyboardInterrupt:
app.destroy() #destroy inbox
```
## Usage Async
```python
import asyncio
import logging
from xtempmail.aiomail import EMAIL, EmailMessage, Email
log = logging.getLogger('xtempmail')
log.setLevel(logging.INFO)
app = Email(name='krypton', ext=EMAIL.MAILTO_PLUS)
@app.on.message()
async def baca(data: EmailMessage):
print(f"\tFrom: {data.from_mail}\n\tSubject: {data.subject}\n\tBody: {data.text}\n\tReply -> Delete")
ok = []
for i in data.attachments: # -> Forward attachmen
ok.append(( i.name, await i.download()))
if data.from_is_local:
await data.from_mail.send_message(data.subject, data.text, multiply_file=ok) # -> Forward message
await data.delete() #delete message
@app.on.message(lambda msg:msg.attachments)
async def get_message_media(data: EmailMessage):
print(f'Attachment: {[i.name for i in data.attachments]}')
@app.on.message(lambda x:x.from_mail.__str__().endswith('@gmail.com'))
async def getGmailMessage(data: EmailMessage):
print(f'Gmail: {data.from_mail}')
if __name__ == '__main__':
try:
loop = asyncio.new_event_loop()
loop.run_until_complete(app.listen())
except Exception:
asyncio.run(app.destroy())
```
## Demo