GithubHelp home page GithubHelp logo

pymail-io's Introduction

PyPI PyPI - Python Version Read the Docs (version)

PyMailIO

An Asynchronous mail server that's built on CPython's AsyncIO library.

Read the docs: Documentation

pip install pymail-io

# Install & run Redis
docker run redis

Quick Start

Run PyMailIO as a complete emailing solution:

from pymail_io.pymailio_task import Task

p = Task(
    password="wizard",
    receiver_email="[email protected]", # Or a list of emails receiver_email=["[email protected]", ...],
    sender_email="[email protected]",
    email_host="smtp.gmail.com",
)
# if you are running PyMailIO within the life time of a long running process, such as
# a web framework of rest API, then set `run_forever=True` as this will yield much
# better performances.

Create your email subject & body

r = p.send_email(
    subject="The subject...",
    body="The email body...",
)

The response from calling p.send_email:

"""

{
    "metadata": { # metadata... },
        "email": {
            "subject": subject,
            "body": body,
            "email_init": # time that PyMailIO sent your email,
    }
}
"""

To get the results of the email from the store, pass the metadata to get_email_response. For example:

# r is the return value from calling p.send_email (see above)
r = p.send_email(
    subject="The subject...",
    body="The email body...",
)

email_meta = p.get_email_response(r)

There are 2 datetime values that reference when PyMailIO executed the send_email method & also when the email was actually sent from the background queue: The datetime_exec method will give you the datetime value that PyMailIO executed the send_email method. For example:

r = p.send_email(
    subject="The subject...",
    body="The email body...",
)

self.datetime_exec()

There are 2 datetime values that reference when PyMailIO executed the send_email method & also when the email was actually sent from the background queue: The exec_time method will give you the datetime value that PyMailIO's queue executed the send_email method. For example:

r = p.send_email(
    subject="The subject...",
    body="The email body...",
)

# Some time in the future...
r = get_email_response(r)
time_email_sent = self.exec_time(r)

To update the task queue & store settings, you can pass in extra values as kwargs to the Task class. For example:

p = Task(
   password="wizard",
   receiver_email="[email protected]",  # Or a list of emails receiver_email=["[email protected]", ...],
   sender_email="[email protected]",
   email_host="smtp.gmail.com",

   # extra settings:
    store_port=6379,
    store_host="localhost",
    db=0,
    workers=1,
)

Built With

  • PyTaskIO - Asynchronous Tasks Library using asyncio

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

This library is based on & influenced by flask-mail.

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.