Hi everyone! We use the EmailTask in prefect.tasks...
# prefect-community
e
Hi everyone! We use the EmailTask in prefect.tasks.notifications to send mail notifications from our Prefect flows via smtp-mail.outlook.com. Unfortunately, this class utilizes basic authetication implementation. Due to deprecation of basic authentication in Exchange Online, we now need to switch to modern authentication for all of our services. Does anyone know if Prefect has implemented this or has plans to do so? Otherwise, has anyone else implemented this using other libraries eg. from Microsoft? Thank you in advance. Can this be fixed by using smtp_type = SSL? Do we have to deal with certificates in order to switch to SSL? Extract of the code we use:
Copy code
mail_settings = {
    "mail_title": "Title",
    "mail_recipient": "<mailto:recipient.1@enova.no|recipient.1@enova.no>,recipient.2@enova.no",
    "mail_sender": "<mailto:sender@enova.no|sender@enova.no>",
    "mail_smtp_server": "<http://smtp-mail.outlook.com|smtp-mail.outlook.com>",
    "mail_smtp_port": 587,
    "mail_smtp_type": "STARTTLS",
}

with case(new_file, True):
        email_sent = email(
            subject=mail_settings["mail_title"],
            email_to=mail_settings["mail_recipient"],
            email_from=mail_settings["mail_sender"],
            smtp_server=mail_settings["mail_smtp_server"],
            smtp_port=mail_settings["mail_smtp_port"],
            smtp_type=mail_settings["mail_smtp_type"],
            msg_plain=email_body,
            attachments=[most_recent_file["local_path"]],
        )
1
a
Can you try passing SMTP type INSECURE?
Copy code
EmailTask(subject='xxx', msg='Hi!', email_to='xxx', email_from='xxx', smtp_server='xxx',smtp_port=25, smtp_type='INSECURE')
I feel bad about this INSECURE type, but another user seemed to have used it as a successful workaround I doubt we would change that in Prefect 1.0 since the focus is on 2.0, but we'll review and merge a PR if you would like to contribute
e
Thanks a lot for your feedback. We will also focus on upgrade path to Prefect 2.0, so if things are taken care of there, we will not spend to much energy on this one right now...
🙌 1
a
This totally makes sense!
j
Hi everyone, We are facing the same issue. Our processes are very simple. We are going to start migrating some processes soon, and I wanted to know if Prefect 2.0 considers something like Emai_Task, but with Multifactor Authentication (MFA) ?
a
we do have a Prefect Collection where you could help contribute such task https://github.com/PrefectHQ/prefect-email
👍 1
but e.g. if you need it for alerts on failed flow runs, we have email Notifications feature available out of the box when you sign up for Cloud