Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

add unverified-context to credentials #70

Closed
wants to merge 2 commits into from

Conversation

sm-ghavami
Copy link

@sm-ghavami sm-ghavami commented Oct 6, 2023

Closes 69
This PR is going to add support for unverified smtp servers to prefect-email.

Example

from prefect import flow
from prefect.context import get_run_context
from prefect_email import EmailServerCredentials, email_send_message

credentials = EmailServerCredentials(
    username="EMAIL-ADDRESS-PLACEHOLDER",
    password="PASSWORD-PLACEHOLDER",
    smtp_type="STARTTLS",
    unverified_context=True
)
credentials.save("email-server-credentials")

def notify_exc_by_email(exc):
    context = get_run_context()
    flow_run_name = context.flow_run.name
    email_server_credentials = EmailServerCredentials.load("email-server-credentials")
    email_send_message(
        email_server_credentials=email_server_credentials,
        subject=f"Flow run {flow_run_name!r} failed",
        msg=f"Flow run {flow_run_name!r} failed due to {exc}.",
        email_to=email_server_credentials.username,
    )

@flow
def example_flow():
    try:
        1 / 0
    except Exception as exc:
        notify_exc_by_email(exc)
        raise

example_flow()

Screenshots

image

Checklist

  • References any related issue by including "Closes #" or "Closes ".
    • If no issue exists and your change is not a small fix, please create an issue first.
  • Includes tests or only affects documentation.
  • Passes pre-commit checks.
    • Run pre-commit install && pre-commit run --all locally for formatting and linting.
  • Includes screenshots of documentation updates.
    • Run mkdocs serve view documentation locally.
  • Summarizes PR's changes in CHANGELOG.md

@sm-ghavami sm-ghavami requested a review from a team as a code owner October 6, 2023 12:24
@desertaxle
Copy link
Member

Thank you for your willingness to contribute to prefect-email! The code for this library has been moved to https://github.com/PrefectHQ/prefect/tree/main/src/integrations/prefect-email. Please reopen this PR there if this functionality is still needed!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support of unverified smtp server
2 participants