Skip to main content

Temporary Email

Project description

Unittest Upload to PyPi

Temporary Mail

Tempmail client for tempmail.plus

Installation

$ 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

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

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, 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xtempmail-0.9.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file xtempmail-0.9.tar.gz.

File metadata

  • Download URL: xtempmail-0.9.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for xtempmail-0.9.tar.gz
Algorithm Hash digest
SHA256 0dac554281b4736799abfe0be41611ed3333d8ef06e61bf46662971cd68e2e9f
MD5 46cf59ffe4efb8fdbde9cb9f05121124
BLAKE2b-256 0b5057d79b4d62ea2ea7fd65b1bb119ee313691b62e64941c2a7f0a8cade527c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page