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

SMTP Enum is saved instead of Name on Email Server Credentials block #54

Closed
masonmenges opened this issue Jan 30, 2023 · 0 comments · Fixed by #56
Closed

SMTP Enum is saved instead of Name on Email Server Credentials block #54

masonmenges opened this issue Jan 30, 2023 · 0 comments · Fixed by #56
Labels
bug Something isn't working

Comments

@masonmenges
Copy link

masonmenges commented Jan 30, 2023

Utilizing the Email Server credentials block results in an error when the SMTP Type enumeration is specified

from prefect_email import EmailServerCredentials, SMTPType

email_server_credentials = EmailServerCredentials(
    smtp_server="[us-smtp-outbound-1.mimecast.com](https://us-smtp-outbound-1.mimecast.com/)",
    smtp_type=SMTPType.STARTTLS,
    smtp_port=587,
    username="username",
    password="password"
)
email_server_credentials.save("email-credentials3", overwrite=True)
creds = EmailServerCredentials.load("email-credentials3")
print(creds.smtp_type)

Whereas if the a string is used to specify the SMTP type the block functions correctly

email_server_credentials = EmailServerCredentials(
        smtp_server="[us-smtp-outbound-1.mimecast.com](https://us-smtp-outbound-1.mimecast.com/)",
        smtp_type="STARTTLS",
        smtp_port=587,
        username="username",
        password="password"
    )

    email_server_credentials.save("email-credentials3", overwrite=True)

    creds = EmailServerCredentials.load("email-credentials3")
    print(creds.smtp_type)

Utilizing the block returns this error:

Encountered exception during execution: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/prefect/[engine.py](https://engine.py/)", line 1478, in orchestrate_task_run result = await task.fn(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/prefect_email/[message.py](https://message.py/)", line 116, in email_send_message with email_server_credentials.get_server() as server: File "/usr/local/lib/python3.10/site-packages/prefect_email/[credentials.py](https://credentials.py/)", line 130, in get_server smtp_type = _cast_to_enum(self.smtp_type, SMTPType, restrict=True) File "/usr/local/lib/python3.10/site-packages/prefect_email/[credentials.py](https://credentials.py/)", line 57, in _cast_to_enum raise ValueError(f"Must be one of {valid_enums}; got {obj!r}") ValueError: Must be one of ['SSL', 'STARTTLS', 'INSECURE']; got '587'

@ahuang11 ahuang11 added bug Something isn't working labels Jan 30, 2023
@ahuang11 ahuang11 mentioned this issue Feb 6, 2023
5 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants