Skip to content




prefect-email is a collection of prebuilt Prefect tasks that can be used to quickly construct Prefect flows that interacts with email services.

Getting Started

Python setup

Requires an installation of Python 3.7+.

We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.

These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.


Install prefect-email with pip:

pip install prefect-email

Then, register to view the block on Prefect Cloud:

prefect block register -m prefect_email

Note, to use the load method on Blocks, you must already have a block document saved through code or saved through the UI.

Send an email using Gmail

from prefect import flow
from prefect_email import EmailServerCredentials, email_send_message

def example_email_send_message_flow():
    email_server_credentials = EmailServerCredentials(
    subject = email_send_message(
        subject="Example Flow Notification using Gmail",
        msg="This proves email_send_message works!",
    return subject


Please note, many email services, like Gmail, require an App Password to successfully send emails. If you encounter an error similar to smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted..., it's likely you are not using an App Password.


If you encounter any bugs while using prefect-email, feel free to open an issue in the prefect-email repository.

If you have any questions or issues while using prefect-email, you can find help in either the Prefect Discourse forum or the Prefect Slack community.

Feel free to ⭐️ or watch prefect-email for updates too!


If you'd like to install a version of prefect-email for development, clone the repository and perform an editable install with pip:

git clone

cd prefect-email/

pip install -e ".[dev]"

# Install linting pre-commit hooks
pre-commit install