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

82
Visualizações
MIME Message, missing fields in mail

I have this function MIME message that I then POST to google draft API. When manually checking in my drafts, the mailContent show's up properly.

  const mailContent = req.body.content

  .
  .
  .


  var message = 'MIME-Version: 1.0\r\n' +
  'Content-type: multipart/alternative; boundary=boundaryboundary\r\n\r\n' +
  '--boundaryboundary\r\n' +
  'Content-type: text/plain; charset=UTF-8\r\n' +
  mailContent + "\r\n\r\n" +
  '--boundaryboundary--';

Now I'm trying to add the From, To and Subject fields in my MIME message, and after quite some research, I thought that adding them to the 'body' like so would do the trick:

  const mailContent = req.body.content
  const from = "exyleprod@gmail.com"
  const to = req.body.to || ""
  const subject = req.body.subject || ""
  .
  .
  .

  var message = 'MIME-Version: 1.0\r\n' +
  'Content-type: multipart/alternative; boundary=boundaryboundary\r\n\r\n' +
  'From: SomeName ' + '<' + from + '>' + "\r\n" +
  'To: ' + '<' + to + '>' + "\r\n" +
  'Subject: ' + subject + "\r\n" +
  '--boundaryboundary\r\n' +
  'Content-type: text/plain; charset=UTF-8\r\n' +
  mailContent + "\r\n\r\n" +
  '--boundaryboundary--';

But it doesn't... I've tried logging the added fields and they are what I expect. The POST still work's and successfully create's an other draft with the mailContent. However, the 3 fields I'm trying to add don't show up. An I doing this wrong ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try to do it this way:

var message = {
  from: "sender@example.com",
  to: "receiver@example.com",
  subject: "Message title",
  text: "Plaintext version of the message",
  html: "<p>HTML version of the message</p>"
};
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