Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda