Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
AWS sendRawEmail - InvalidParameterValue: Empty header names are illegal

I'm using the latest JS SDK, and cannot send a raw email without a confusing error.

Here's my code:

  const msg = mimemessage.factory({
    contentType: 'text/plain',
    contentTransferEncoding: 'base64',
    body: 'hello world'
  })

  msg.header('From', 'Admin <hello@condobeaver.com>')
  msg.header('To', destination)
  msg.header('Subject', 'Customer service contact info')

  const command = new SendRawEmailCommand({
    Destinations: [destination],
    Source: 'hello@condobeaver.com',
    RawMessage: { Data: msg.toString() }
  })

  console.log(command)

  const response = await client.send(command)

The output of command is:

SendRawEmailCommand2 {
  middlewareStack: {
    add: [Function: add],
    addRelativeTo: [Function: addRelativeTo],
    clone: [Function: clone],
    use: [Function: use],
    remove: [Function: remove],
    removeByTag: [Function: removeByTag],
    concat: [Function: concat],
    applyToStack: [Function: cloneTo],
    resolve: [Function: resolve]
  },
  input: {
    Destinations: [ 'ilia.reingold@gmail.com' ],
    Source: 'hello@condobeaver.com',
    RawMessage: {
      Data: 'Content-Type: text/plain\r\n' +
        'Content-Transfer-Encoding: base64\r\n' +
        'From: Admin <hello@condobeaver.com>\r\n' +
        'To: ilia.reingold@gmail.com\r\n' +
        'Subject: Customer service contact info\r\n' +
        '\r\n' +
        'hello world'
    }
  }
}

It seems to have everything I need: to/from/subject/content.

Yet when I run it, I get:

InvalidParameterValue: Empty header names are illegal.

What header is empty?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The JS SDK takes care of the base64 encoding for you, so you don't need to encode the msg before sending.

  const msg = mimemessage.factory({
    contentType: 'text/plain',
    body: 'hello world'
  })

  msg.header('From', 'Admin <hello@condobeaver.com>')
  msg.header('To', destination)
  msg.header('Subject', 'Customer service contact info')

  const command = new SendRawEmailCommand({
    Destinations: [destination],
    Source: 'hello@condobeaver.com',
    RawMessage: { Data: msg.toString() }
  })

  console.log(command)

  const response = await client.send(command)

(Notice the contentTransferEncoding: 'base64' is removed)

If you get

TypeError: Cannot read property 'byteLength' of undefined

just replace RawMessage: { Data: msg.toString() } with RawMessage: { Data: Buffer.from(msg.toString()) }

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda