Skip to content

Brevo transport replyTo broken #114

@bendulum

Description

@bendulum

Package version

9.2.2

Describe the bug

adonisjs/mail@9.2.2 internally converts replyTo object to an array. This format is not supported by Brevo and transport fails with error 400.

for example config/mail.ts

replyTo: {
    address: env.get('MAIL_REPLY_TO'),
    name: env.get('MAIL_NAME'),
},

is converted to:

"replyTo":[
  {
     "address":"info@myapp.app",
     "name":"myapp"
  }
]

before it's sent to the Brevo API endpoint.
adonis logs show:

{
   "level":50,
   "time":1768327200490,
   "pid":5116,
   "hostname":"xxx",
   "name":"xxx",
   "err":{
      "type":"EmailTransportException",
      "message":"Unable to send email using the brevo transport: Request failed with status code 400 (Bad Request): POST https://api.brevo.com/v3/smtp/email",
      "stack":"EmailTransportException: Unable to send email using the brevo transport\n    at NodeMailerTransport2.send (file:///var/www/build/node_modules/@adonisjs/mail/src/transports/brevo.ts:149:9)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\ncaused by: HTTPError: Request failed with status code 400 (Bad Request): POST https://api.brevo.com/v3/smtp/email\n    at Request.<anonymous> (file:///var/www/build/node_modules/got/dist/source/as-promise/index.js:98:42)\n    at Object.onceWrapper (node:events:639:26)\n    at Request.emit (node:events:536:35)\n    at Request._onResponseBase (file:///var/www/build/node_modules/got/dist/source/core/index.js:779:22)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at Request._onResponse (file:///var/www/build/node_modules/got/dist/source/core/index.js:829:13)",
      "name":"EmailTransportException",
      "status":400,
      "code":"E_MAIL_TRANSPORT_ERROR"
   },
   "msg":"Email transport error"
}

My current workaround is not set replyTo anywhere. Then email transport works.
Is there another workaround?
Will this be addressed in the next update?
Thank you.

Reproduction repo

No response

Metadata

Metadata

Assignees

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