Skip to content

validationError: 1 validation error for EmailContact email when trying .bcc -> Input should be a valid string #187

@iorobertob

Description

@iorobertob

Describe the bug
When running with the example bcc provided in the documenation:

email = (EmailBuilder()
        .from_email(mail_from, name_from)
        .to_many([{"email":borrower_email, "name":borrower_name}])
        .bcc([
            {"email": "bcc1@example.com", "name": "BCC User 1"},
            {"email": "bcc2@example.com"}
         ])
        .subject(subject)
        .html(html_content)
        .text(plain_text_content)
        .build())

response = ms.emails.send(email)

An error is thrown because of the .bcc section, no matter how i format it, with variables or directly pasting the example given it always fails to this:

INFO:werkzeug:127.0.0.1 - - [03/Nov/2025 09:08:58] "POST /book/1 HTTP/1.1" 500 -
Traceback (most recent call last):
  File ".../venv/lib/python3.12/site-packages/flask/app.py", line 1536, in __call__
    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.12/site-packages/werkzeug/middleware/proxy_fix.py", line 183, in __call__
    return self.app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.12/site-packages/flask/app.py", line 1514, in wsgi_app
    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../venv/lib/python3.12/site-packages/flask/app.py", line 1511, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.12/site-packages/flask/app.py", line 919, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.12/site-packages/flask/app.py", line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.12/site-packages/flask/app.py", line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../main.py", line 341, in book_item
    response = send_email(  borrower_email= borrower_contact,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../main.py", line 820, in send_email
    .bcc([
     ^^^^^
  File ".../venv/lib/python3.12/site-packages/mailersend/builders/email.py", line 154, in bcc
    self._bcc.append(EmailContact(email=email, name=name))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.12/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for EmailContact
email
  Input should be a valid string [type=string_type, input_value=[{'email': 'bcc1@example....l': 'bcc2@example.com'}], input_type=list]
    For further information visit https://errors.pydantic.dev/2.12/v/string_type

To Reproduce
Steps to reproduce the behavior:

  1. Create Python venv 3.12 and activate it
  2. Install mailersend 2.0.0 from pip
  3. Run the sample code in a script
  4. Get the returned error message

Expected behavior
No exception thrown

Environment (please complete the following information):

  • OS: macOS Tahoe 26
  • Python version 3.12
  • SDK version 2.0.0

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions