An asynchronous mail server
Project description
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="joe@blogs.com", # Or a list of emails receiver_email=["joe@blogs.com", ...],
sender_email="your_email@gmail.com",
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="joe@blogs.com", # Or a list of emails receiver_email=["joe@blogs.com", ...],
sender_email="your_email@gmail.com",
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
- Joe Gasewicz - Initial work - JoeGasewicz
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.
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
File details
Details for the file pymail-io-0.0.4.tar.gz
.
File metadata
- Download URL: pymail-io-0.0.4.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 289670495fb2033dc8f33281acfef89dd363b9f6e2b335fc94124059cbde9f61 |
|
MD5 | 0b7946dd47acf89a7282e783c3a85853 |
|
BLAKE2b-256 | 0dcb48d9b77c4ff49e3793b847f635bc3b83e1353138f96a517c032fd0962e56 |