Skip to content

Self-hosted AI workspace.

Python
1.1 KB
Raw Blame
"""Regression: SMTP envelope recipients must be parsed, not split on bare commas.

The send paths built the RCPT TO list with `field.split(",")`, which corrupts a
display name containing a comma (e.g. `"Smith, John" <[email protected]>`, the common
Outlook / corporate address-book form): it splits into `"Smith` and
`John" <[email protected]>`, so the broken fragments are handed to smtp.sendmail and
delivery fails. `_envelope_recipients` uses email.utils.getaddresses instead.
"""
import routes.email_routes as email_routes


def test_display_name_with_comma_yields_one_address():
    assert email_routes._envelope_recipients('"Smith, John" <[email protected]>') == ["[email protected]"]


def test_multiple_plain_addresses():
    assert email_routes._envelope_recipients("[email protected], [email protected]") == ["[email protected]", "[email protected]"]


def test_to_cc_bcc_combined_and_none_safe():
    got = email_routes._envelope_recipients('"Doe, Jane" <[email protected]>, [email protected]', None, "[email protected]")
    assert got == ["[email protected]", "[email protected]", "[email protected]"]


def test_empty_and_none_fields():
    assert email_routes._envelope_recipients("", None) == []