resend / resend-python

resend's python sdk
MIT License
58 stars 6 forks source link

Incorrect 'to' Field Handling When Sending Emails to Multiple Addresses #65

Closed brenonsc closed 5 months ago

brenonsc commented 5 months ago

Bug Description

When attempting to send an email to multiple addresses using the resend service, if one of the email addresses is invalid and does not follow the email@example.com or Name email@example.com format, the service returns a 422 error with the message: "Invalid 'to' field. The email address needs to follow the email@example.com or Name email@example.com format." However, the issue is that this error is applied to all email addresses provided, causing the email not to be sent to any of them.

Expected Behavior

The expected behavior should be that if there is an error in one of the email addresses, the resend service should still attempt to send the email to the remaining valid addresses and provide details about the specific invalid address.

Steps to Reproduce

  1. Use the resend service to send an email to multiple addresses.
  2. Include at least one email address that does not follow the email@example.com or Name email@example.com format.
  3. Observe that the service returns a 422 error for the entire to field, preventing the email from being sent to any address.

Thank you for addressing this issue.

drish commented 5 months ago

hey @brenonsc thanks for reporting this issue 😊

could you confirm to me if the method you're trying to use is the regular send api and not the batch api ?

If its the regular send your code would look something similar to this ?

params = {
    "from": "example@example.com",
    "to": ["example1@e.com", "example2@e.com", "invalid"],
    "subject": "hi",
    "html": "<strong>hello, world!</strong>",
}

resend.Emails.send(params)
brenonsc commented 5 months ago

Hello, @drish

Yes, it is the regular send api, my code looks exactly like this.

Thanks in advance!

drish commented 5 months ago

hey @brenonsc sorry for the delay to reply to you here.

that is the behaviour of the Resend API at the moment, I don't think there are any plans to change for now. you could submit a support ticket on the resend website and ask for that feature to be implemented.

let me know if there's anything else I could help you with

thanks again