Code Monkey home page Code Monkey logo

xtempmail's Introduction

Unittest Upload to PyPi Downloads

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

xtempmail's People

Contributors

krypton-byte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

xtempmail's Issues

Killing the program?

I am writing a script that does more than 1 task. So basically i want to get an email from a certain client but once i recieve it how do i kill the program and continue the next code execution since it keeps on running. There isnt any stop listening function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.