sabuhish / fastapi-mail

Fastapi mail system sending mails(individual, bulk) attachments(individual, bulk)
https://sabuhish.github.io/fastapi-mail/
MIT License
698 stars 81 forks source link

Recipients Validation fails if there is a dash in the name. #144

Closed rponline closed 2 years ago

rponline commented 2 years ago

I try to send an email to people who have a dash in their name. (Happens for example sometimes with double names in German. e.g. Hans-Peter)

message = MessageSchema(
    recipients=my_email_str,
    [...]
)

This input works: my_email_str = "Hans Peter Example <hans-peter@example.com>"

This input fails: my_email_str = "Hans-Peter Example <hans-peter@example.com>" with

pydantic.error_wrappers.ValidationError: 1 validation error for MessageSchema
recipients -> 0
  value is not a valid email address (type=value_error.email)

Having a closer look at the fastapi-mail code, i see that it's actually not supposed to handle
pydantics NameEmail schema (e.g. Example Name \example@example.com\) but pydantics EmailStr schema (e.g. example@example.com).

So, I'm even a bit surprised that the first input actually works. Depending how you look at it, this is now a bug report or a feature request :)

rponline commented 2 years ago

Ok, it seems to be a problem with pydantic: https://github.com/pydantic/pydantic/issues/2955