Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(transports/brevo): brevo allow only one replyTo address #104

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

MaximeMRF
Copy link

@MaximeMRF MaximeMRF commented Oct 11, 2024

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Brevo allow only one replyTo address as a object not a array object

Not valid:

curl -X POST "https://api.brevo.com/v3/smtp/email" \
-H "accept: application/json" \
-H "api-key: xkeysib-dunno" \
-H "Content-Type: application/json" \
-d '{
  "sender": {
    "name": "Sender Name",
    "email": "[email protected]"
  },
  "to": [
    {
      "email": "[email protected]",
      "name": "Recipient Name"
    }
  ],
  "replyTo": [{
    "email": "[email protected]",
    "name": "Reply To Name"
  }],
  "subject": "Your Subject Here",
  "htmlContent": "<html><body><p>Your email content here.</p></body></html>"
}'

Error: {"code":"invalid_parameter","message":"replyTo is not valid"}

If you don't pass a array but an object directly it works perfectly

curl -X POST "https://api.brevo.com/v3/smtp/email" \
-H "accept: application/json" \
-H "api-key: xkeysib-dunno" \
-H "Content-Type: application/json" \
-d '{
  "sender": {
    "name": "Sender Name",
    "email": "[email protected]"
  },
  "to": [
    {
      "email": "[email protected]",
      "name": "Recipient Name"
    }
  ],
  "replyTo": {
    "email": "[email protected]",
    "name": "Reply To Name"
  },
  "subject": "Your Subject Here",
  "htmlContent": "<html><body><p>Your email content here.</p></body></html>"
}'

@thetutlage
Copy link
Member

Thanks for the fix. Can you please share some link to the documentation that has an example of replyTo? It will be helpful for reference in the future

@MaximeMRF
Copy link
Author

@RomainLanz
Copy link
Member

I'm not entirely convinced about the proposed fix.

Rather than just taking the first item from the array, we should either prevent passing an array to this driver, or ensure it's an array with a single item and directly call #formatAddress.

What do you think?

@thetutlage
Copy link
Member

I think the internals of the Mail package shouldn't format data as per the requirements of a driver as they might be different across the drivers.

So, drivers receives a fixed shape and they can change the data for the underlying API call.

@RomainLanz
Copy link
Member

So, drivers receives a fixed shape and they can change the data for the underlying API call.

But it also means I can write an array there, and it will only take the first item out of nowhere. It should be adequately documented.

Nevertheless, we can use this.#formatAddress(mail.data.replyTo[0]) instead.

@thetutlage
Copy link
Member

Yeah, the nuances of the drivers have to be documented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants