https://prefect.io logo
Title
v

Viet Nguyen

08/05/2022, 2:04 PM
Hi all, I'm trying to use
prefect-email
to send some dummy test email (I know there's prefect notifications features) but I want test out
prefect-email
as well, got this error everytime, hard coded password for dummy test, can't be a wrong password 🤔
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8  <https://support.google.com/mail/?p=BadCredentials> d6-20020a170903230600b0016efc27ca98sm3023696plh.169 - gsmtp'
Thank you
from prefect import flow
from prefect_email import EmailServerCredentials, email_send_message

@flow
def example_email_send_message_flow():
    email_server_credentials = EmailServerCredentials(
        username="<mailto:username@email.com|username@email.com>",
        password="password",
    )
    subject = email_send_message(
        email_server_credentials=email_server_credentials,
        subject="Example Flow Notification",
        msg="This proves email_send_message works!",
        email_to="<mailto:someone@email.com|someone@email.com>",
    )
    return subject

example_email_send_message_flow()
i'm testing with a Google email account
k

Khuyen Tran

08/05/2022, 3:29 PM
@alex Maybe you know why?
a

Andrew Huang

08/05/2022, 3:44 PM
Yes you need to set up a app password; gmail is strict about using app passwords if not logging in through their UI https://support.google.com/accounts/answer/185833
v

Viet Nguyen

08/05/2022, 6:20 PM
thank you, when I tried to use with an outlook account, it shows the same message, how can I configure SMTPServer myself with prefect-email? Thank you
a

Andrew Huang

08/05/2022, 6:22 PM
Call
credentials.SMTPServer.OUTLOOK
🙌 1
v

Viet Nguyen

08/05/2022, 6:48 PM
thank you
a

Andrew Huang

08/05/2022, 6:51 PM
No problem!
You may also need to up smtp_type, depending on what outlook supports